in reply to An IO::Sockets 'test for live connection' question:
This should make the socket go bad before you come to write to it. But really, what's the point of that? You're still going to have to do error handling on the print/write anyway (to catch other errors, or a server reboot which occurs after your last keepalive but before your write).
If you write to a broken socket on Unix/Linux, your application should receive a SIGPIPE, which is ordinarily fatal. Install a signal handler for that (or ignore - but it's better to handle+log on SIGPIPE) and make sure you check errno (a.k.a. $!) for EPIPE errors after you do any write to a socket. If you try to write a request and it fails, and errno is EPIPE, then reconnect and try again.
This is the low-level description of what your (Unix) app needs to do. Various higher-level convenience layers may exist for your protocol, depending on what it is.
(There's lots more low-level info in places like "man 7 socket" if you're interested). Good luck.
|
|---|