RE: [PHP] PHP Sockets - How to detect client disconnection?
| From: | Aras | Date: | Sat, 06 Jan 2007 21:26:15 +0000 |
| Subject: | RE: [PHP] PHP Sockets - How to detect client disconnection? | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-246693@lists.php.net to get a copy of this message | ||
I used Process Control Functions in PHP and installed some signals to catch
socket disconnection.
My attempt to do this in loops were a harder way or i could not manage it.
There must be some notes about this in archives or i can send some of my
code so that you can have a look at them.
Aras Koktas
manager@phidot.com
Business Excellence Development
Phi.dot Internet Systems
-----Original Message-----
From: Anthony Rasmussen [mailto:evoluenta@hotmail.com]
Sent: Saturday, January 06, 2007 11:12 PM
To: php-general@lists.php.net
Subject: [PHP] PHP Sockets - How to detect client disconnection?
How do I detect a disconnected client from a socket resource?
In an infinite loop, I socket_read() every open resource that passes a
socket_select().
As far as I know, the only way to detect if the client disconnected
unexpectedly from their socket resource is when socket_read() returns FALSE
(which, during my testing, produced the warning: "An established connection
was aborted by the software in your host machine.").
However, socket_read() doesn't return FALSE on a disconnected client's
socket resource until I first attempt to socket_write() to that resource.
In brief pseudo code...
socket_create(AF_INET, SOCK_STREAM, SOL_TCP)
while (TRUE)
foreach (resource where (false === socket_select($arrayofresources, NULL,
NULL, 0, 0))
if (socket_read() === false)
WON'T DETECT DISCONNECT UNTIL I FIRST socket_write()
I appreciate any support you offer and thank you for your time.
Best regards,
-Tony
_________________________________________________________________
Type your favorite song. Get a customized station. Try MSN Radio powered
by Pandora.
http://radio.msn.com
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php