in reply to Re: IO::Socket Timeouts
in thread IO::Socket Timeouts

The main problem is that the perl process which runs on the client machine will appear to sit there forever if there was some sort of a network issue. I'd like to have it essentially timeout so it can reset itself and try the connection again in a few minutes.

The general concept here is that these clients periodically connect to the server to send/receieve any data that needs to be transferred. Right now, if there is any kind of a network glitch during a transfer (which seems to happen with a few of these clients that have dodgy DSL lines), the client will sit there forever. I'm trying to come up with a relatively clean way for the client machine to realize it has taken way too long, and that it should give up and just attempt a new connection during its next update window.

Replies are listed 'Best First'.
Re^3: IO::Socket Timeouts
by shmem (Chancellor) on Oct 10, 2006 at 22:26 UTC
    Well, then I'd go with alarm on the client side, and re-set the alarm after each successful read or send. Then there's the is_connected method of IO:Socket. In the handler, I'd check with $socket->is_connected, shutdown the socket and reconnect. I can think of no better way to handle forever_futile than alarm().

    --shmem

    --shmem

    _($_=" "x(1<<5)."?\n".q·/)Oo.  G°\        /
                                  /\_¯/(q    /
    ----------------------------  \__(m.====·.(_("always off the crowd"))."·
    ");sub _{s./.($e="'Itrs `mnsgdq Gdbj O`qkdq")=~y/"-y/#-z/;$e.e && print}