I am writing a program on a pc that is controlled via a php script on a server. I am currently using php to ftp a file back and forth and using the c# to read the file and execute commands based on the data in the file. However this is not an ideal solution.
I would like to see a tutorial or example on how to use php to send data to a c# program pver sockets.
Example of data I would like to send
1:control1
1:control2
1:control3
0:control4
0:control5
Can anyone point me in the right direction?
Rather than try and get your server-sided PHP script to send data to the C# program, which will give you a heap of headaches, why not write something on the PHP script that, given a specific request to the page, outputs the currently queued instructions? The C# program can then just make a WebRequest to the page and receive its instructions.
For example:
== PHP SCRIPT ==
Now to actually retrieve data from the request:
== C# Client Code ==
This is a rough template with minimal error handling, hopefully it’s enough to get you started.
EDIT: Woops, forgot to include an example usage: