A community in which webmasters can ask for help with topics such as PHP coding , MySQL , IT jobs, web design, IT security.
Current location:homephp forumphp talk in 2009 yearPHP webserver connect to C# program on same server — What am I looking for? - page 1
User InfoPosts
PHP webserver connect to C# program on same server — What am I looking for?#1
So I have a webserver in which user can remotely control an external electronic board which due to certain conditions force me to put a desktop program using C# as the middle-man.

What is the magic keyword I(m looking for? At first I thought of socket but every socket searches involve server-client over TCP... it(s the same machine so theoretically I can just put loopback address and proceed normally. But is this an overkill way or the only way?

Thanks in advance.

edit: My C# program is basically a daemon which will wait orders from the PHP script. So I can remotely access that website and instruct that C# app.

posted date: 2009-04-07 03:50:00


Re: PHP webserver connect to C# program on same server — What am I looking for?#2
I had made out the solution of this problem. click to view my topic...

hope that hepls.

posted date: 2009-04-07 03:50:01


Re: PHP webserver connect to C# program on same server — What am I looking for?#3
I(m not 100% sure what you mean. I assume you want to call a C# app from within a php script. If so, maybe this will help:function execute($command, $stdin) {$pipes = array();$process = proc_open($command, array(array((pipe(, (r(), array((pipe(, (w(), array((pipe(, (w()), $pipes);if ($stdin) fwrite($pipes[0], $stdin);fclose($pipes[0]);$stdout = ((;while(!feof($pipes[1])) $stdout .= fgets($pipes[1], 1024);fclose($pipes[1]);$stderr = ((;while(!feof($pipes[2])) $stderr .= fgets($pipes[2], 1024);fclose($pipes[2]);$return_value = proc_close($process);return array($stdout, $stderr, $return_value);}Where $command is the path and file name of your c# app (plus any command line params) and if needed $stdin is, well, standard input to your c# app.If your C# app is listening on a particular port (lets say 8888) for requests, maybe you(re looking for:$handle = fopen("http://localhost:8888/someurl?someparam=somevalue", "r");

posted date: 2009-04-07 04:10:00


Re: PHP webserver connect to C# program on same server — What am I looking for?#4
Note that this references using a console app, which may well be a better method.

posted date: 2009-04-07 04:37:00


Re: PHP webserver connect to C# program on same server — What am I looking for?#5
No, I want to pass a message to the C# app that should always be running. Read my edit.

posted date: 2009-04-07 04:41:00


Re: PHP webserver connect to C# program on same server — What am I looking for?#6
Is the C# daemon listening on a port for requests?

posted date: 2009-04-07 04:56:00


Re: PHP webserver connect to C# program on same server — What am I looking for?#7
I would suggest client/server architecture using TCP/IP (or even UDP) (or another MS messaging protocol) in order to talk to your C# program. What you are effectively doing is writing a device driver for a specialized piece of hardware. By making it client/server you can:Shift the code into a Windows service which can run on any machine your web server can connect to, not just the local machine.Easily have the server handle multiple connections, so that clients other than your web server can access the hardware and the access contention is handled in a rational manner. Think test console for debugging/testing the hardware.Add a cool line to your resume about writing client/server systems and windows services!Probably some other benefits that I can(t think of now :-)EditIf written with care, you can also abstract the service to handle multiple devices at the same time

posted date: 2009-04-07 04:57:00


Re: PHP webserver connect to C# program on same server — What am I looking for?#8
XML-RPC and SOAP are designed for application-to-application communication.

posted date: 2009-04-09 12:08:00


select page: « 1 »
Copyright ©2008-2017 www.momige.com, all rights reserved.