If you are strictly a consumer of data provided by the server, (you only do reads), there is no notification that the server died. You have to infer that it died by noticing that you haven't received anything from it for awhile, usually via an alarm timout via a SIGALRM signal.
If you write to a socket where the reader has gone away, that triggers a SIGPIPE signal.
Your recursive call is weird. You can chew a lot of stack space this way and for nought. Also if connect is failing due to something other than the timeout, your code could bombard the poor server with a huge number of requests and very quickly and all the while burning lots of stack. A simple while loop should suffice, like this or whatever you want anything except pushing deeper into the stack.
my $socket; while ( !$socket = IO::Socket::INET->new ( Proto => "tcp", PeerAddr => "192.168.1.105", PeerPort => "5000", Timeout => "1") ) { sleep 1; #or other backoff algorithm here }
In reply to Re: IO::Socket client does not detect when server network connection dies
by Marshall
in thread IO::Socket client does not detect when server network connection dies
by bkchris
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |