BlaisePascal has asked for the wisdom of the Perl Monks concerning the following question:
I've got a socket, created with IO::Socket::INET, that I've registered with an IO::select object.
I'm writing to the socket using the following code:
I only have one socket registered with the select, so it only writes to the one socket. This code works fine, except...if (my @s = $select->can_write()) { for (@s) { if (print $_ $message) { print "message sent"; } else { print STDERR "Could not write to socket: $!\n"; } } }
The server I'm talking to has the annoying habit of terminating the connection with no warning. When that happens, the $select->can_write() is not blocking, but immediately returns the one registered socket (which was closed from the other end), and the print fails.
Is can_write() supposed to return a handle that I clearly cannot write to? If so, what suggestions can I get for bulletproofing my code?
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Stupid IO::select question
by ferrency (Deacon) on Aug 03, 2000 at 21:42 UTC | |
|
Re: Stupid IO::select question
by tye (Sage) on Aug 04, 2000 at 08:29 UTC |