On Wed, May 22, 2002 at 10:16:23AM -0000, Vinod  Panicker wrote:
> 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 :)
Not quite!

Keep-alive tries to keep a socket connection with the server, but this connection
can only be used to request several resources from the servers (like the
images inside a page). This because setting up a new tcp-connection takes a lot
of time, keep-alive just reuse this connection for another request. The server itself 
cannot
*start* sending data over the http connection, it can only reply on a client request.

What you can do however, is to create a script with an endless loop, inside
this loop the scripts looks if there's new data in a database and if there's
data, it's sent to the client.. You can ofcourse also do other things inside
the loop. 

But you won't need a keep-alive connection for this. Ohh, don't use any out
buffering, otherwise the browser will timeout after 30 seconds..  ;-)

However the server can't switch pages. What you can do, is inside the loop
to access a different page with the fopen function.

Hope this will answer your question,

-- 
With best regards,

Dave Mertens, Development Manager
[EMAIL PROTECTED]

Innovative Solutions in Media BV
Schiekade 101
3033 BG  Rotterdam, Netherlands
Tel. +31-10-2436060
Fax. +31-10-2436066

-- 
PHP Development Mailing List <http://www.php.net/>
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to