Answer the question
In order to leave comments, you need to log in
How to establish "communication" between a PHP script and a C# program on Windows?
The task is exotic, of course, but still. There is a PHP script (PHP7) that runs in Windows 7 in multi-threaded mode (and constantly hangs in memory). There is a C# utility. It is necessary to connect them with each other with a high data transfer rate between them. What is the best way to do this? Through sockets? Through an extension to PHP DOTNET? (if so, what tools of the .NET framework should be used?)
Don't suggest rewriting everything - of course, it would be worth doing in a good way, but this task is too insignificant to spend a lot of time on it.
Thank you!
Answer the question
In order to leave comments, you need to log in
The option with sockets has already been suggested to you, but I will add one more way:
For fast data exchange between processes, shared memory is usually used.
That is, the PHP script creates a memory area (shmop_open) and writes the calculation data there, and using the C # utility, you read the data from this area and manipulate them.
Well, to notify the utility that data can be taken, you can use a mutex. That is, again, PHP creates a mutex at startup and occupies it, and the utility also tries to acquire it and "sleeps" in the queue. As soon as the data can be processed - PHP will release the mutex by giving the utility the command "Fas!"
I have not played with PHP on Windows, but I think that there will be no problems with both shared memory and the creation of a mutex (after all, PHP was already able to parallelize =) ).
Through exec and stdout/stdin (though I don't know if the latter is possible from the PHP side).
If you don't feel like reinventing the wheel, you can try Apache Thrift . On Habré there is a small article on this topic (regarding C#).
Depending on what you specifically need, then do it. "Establish communication" is too abstract a concept, all of a sudden you just want to ping a process on a port.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question