socket disconnection
| From: | Thomas Weber | Date: | Sat, 24 May 2003 03:59:45 +0000 |
| Subject: | socket disconnection | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-148822@lists.php.net to get a copy of this message | ||
how can i detect a disconnect from a socket on the client-side and
reconnect?
My clients code looks somewhat like this:
$ipcsocket = socket_create (AF_UNIX, SOCK_STREAM, 0);
socket_connect ($ipcsocket, $server["socket_ipc"]);
if ($out = socket_read ($ipcsocket, 8192)) {
do_something ();
}
I thought if i simply add an else-statement like this
while (!$connected) {
sleep (5);
if (socket_connect ($ipcsocket, $server["socket_ipc"])) $connected =
true;
}
would make it.
I tested it in shutting the server down and see, the disconnect was
identified. As i restartet the server, the script seems to reconnect, but it
tries to reconnect over and over again!
Any idea out there? :(
Thanks,
Thomas 'Neo' Weber
---
thomas@youngarts.org
neo@gothic-chat.de