|
Posted by amygdala on 06/03/07 02:14
"amygdala" <noreply@noreply.com> schreef in bericht
news:46622008$0$25488$9a622dc7@news.kpnplanet.nl...
>
> "Alexey Kulentsov" <crimaniak@crimaniak.com> schreef in bericht
> news:4661b521$0$90262$14726298@news.sunsite.dk...
>> DavidNorep wrote:
>>> I do not know PHP, consider to write a CGI with this technology and
>>> have the following question.
>>>
>>> Is it possible to invoke a PHP script and let it endlessly wait for
>>> requests from a website (a Java applet in my case) and serve the
>>> requests when they arrive? I want to avoid loading the script for each
>>> request.
>> Yes, but only for output. I done web chat with this technology (I call
>> it endless connection) long time ago, before AJAX era. It was PHP script
>> on server-side and javascript on client-side. You need set_time_limit()
>> to prevent timeout on server so you can't do it in safe mode. And you
>> need to send periodically something to prevent timeout on client. Request
>> sent to additional short script who put it to database or another place.
>> Main script in endless loop checks for new requests, process it and sends
>> result back to client.
>> Now here is no reasons to do such things.
>
> Correct me if I'm wrong here, but I thought there was some sort of
> solution for this, using sockets. Or is this perhaps what you are refering
> to already?
>
> I once ran a very small test with socket connections as a command line
> script. My goal was to write a little http chat app. I didn't follow up on
> that anymore. But I had the feeling though that this little script could
> easily be ported to some webserver environment. Probably not too a
> stressful environment, but still.
>
> @ DavidNorep: you mentioned the use of a JAVA applet. I don't know much
> about JAVA but I assume JAVA has some socket interfaces itself too, no?
> This could rule out client timeouts I think.
>
> Also, I vaguely recall the script didn't need to loop, it would just
> listened to a socket, and started doing things as soon as it got input on
> the socket. I'll have look around to see if I can find the script.
Forget what I said about not having to loop. It *did* need to loop. I found
the core of the script I used in the PHP manual under Socket Functions. I
remember again.
HTH
[Back to original message]
|