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?
In reply to Stupid IO::select question by BlaisePascal
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |