How do I get a PHP script to send and receive data from an already running process?

I am trying to create a simple AJAX for a Telnet client for the Internet. I can reinvent the wheel by doing this, but for me this is a tutorial project. I haven't written anything at this point, I'm just trying to figure out that the idea is wrapped around my brain. It doesn't have to be PHP.

If I have a telnet client that supports multiple connections already running in its own process, how do I get the PHP script that fires when the client-browser requests the ability to communicate with the client?

For example, I want a PHP script to be able to tell an already running process which client it is and receive any new data from the telnet process.

+1


source to share


3 answers


For PHP, is your conversation about shell interaction correct? This will depend on the telnet client you are trying to connect to and what CLI options it supports. Opening a stream to do this would probably require each telnet session to output its "STDIO" to a text file, and then PHP read that text file and display the "difference".

With Fsockopen () in PHP, you don't really need to interact with another program, but you can run socket commands directly in PHP and get the results there.



PHP: Fsockopen

+1


source


I would create a telnet client that runs as a daemon process. He will be responsible for creating and maintaining the telnet session and buffering any data received.

Your PHP script can then use a TCP connection or Unix socket to communicate with your telnet client daemon process using the PHP sockets API .



Jim.

+1


source


Even if the connection has to be persistent?

edit: nevermind i think i have an idea.

I'll write the client part myself, but if it can also act as the server that PHP calls by connecting to it and providing the appropriate details so that it can know what connection the user needs ... George I think I have this happened!

edit2: What Jim said. Thanks Jim.

0


source







All Articles