Full-duplex communication
| From: | Vinod Panicker | Date: | Wed, 22 May 2002 10:16:23 +0000 |
| Subject: | Full-duplex communication | ||
| Groups: | php.dev | ||
| Request: | Send a blank email to php-dev+get-84263@lists.php.net to get a copy of this message | ||
Hi,
I had a peculiar requirement. I need the ability to send asynchronous data from my web server to the client (COM component). I know that the first thing ppl will say is not to be using a web server, and to use a TCP solution. Thing is that the system is in a production environment and needs to be optimised.
So i came up with the solution that if I could get hold of the socket on which the client is reading, and store it somewhere, other php scripts or a C++ binary can use the socket to write() to it, and the client on the other end will receive the data.
Putting it in more detail -
The client calls a script on the server - script_a.php using a keep-alive connection. The script gets the socket from the web server (this is the unknown), and stores it in a database. Script finishes execution, client reads response, but apache doesnt close the connection since its keep-alive.
Client wants to call another script on the server, just writes to the same socket. Script returns response.
Server wants to send data asynchronously to the client, so a PHP script (invoked from another server) gets the socket of the client from the database and writes to it. Client reads from the socket.
So this is basically a full-duplex connection over HTTP :)
Only thing to get is the socket :(
Any ideas?
I'm willing to do some coding in C to get this done, if someone can pls direct me where to start... can the PHP module get the socket details from apache?
Or will i have to do a hack on apache itself?
Tx,
Vinod.
_________________________________________________________
Click below to visit monsterindia.com and review jobs in India or Abroad
http://monsterindia.rediff.com/jobs