in reply to Detecting disconnection from client using IO::Socket Objects.
Without really knowing how you have implemented your server, I can give you the following advice if you are doing non-blocking I/O with the help of IO::Select or IO::Poll:
After getting a read-event on the socket, you'll go to do your sysread, and you'll get back 0 bytes. That means the client closed the socket. The following code snippet illustrates:
my $bytes_read = $socket->sysread($buf, $max_read_len); if (not defined $bytes_read) { print "ack! error on the socket\n"; } elsif ($bytes_read == 0) { print "the socket was closed\n"; } else { print "woo hoo! I read $bytes_read bytes from the socket...\n"; }
You might want to look at this node for more info:
Detecting a closed socket
HTH
--
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re: Detecting disconnection from client using IO::Socket Objects.
by Abroxa (Initiate) on Sep 17, 2003 at 17:08 UTC |