bonzi has asked for the wisdom of the Perl Monks concerning the following question:
Here timeout works - an attempt to connect to something that is not listening will fail after the timeout expires. However, setting the read timeout like this:my $sock_Zona = IO::Socket::INET->new( PeerAddr => $par{addr_Zona}, PeerPort => $par{port_Zona}, Proto => "tcp", Type => SOCK_STREAM, Timeout => $par{conn_tmo} );
seems to have no effect. If the instrument for some reason neglects to answer (as they are wont to do), I usually get an empty reply, but sometimes the read from the socket just hangs. I would like to avoid running all reads in separate threads (there are lots of them), if at all possible. Any perl of wisdom greatly appreciated.unless (defined $sock_Zona) { $abort++; $sock_Zona = -1; ABORT("Zona se ne javlja: $!"); } else { IO::Socket::Timeout->enable_timeouts_on($sock_Zona); $sock_Zona->read_timeout($par{read_tmo_Zona}); }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Socket read timeout on Windows
by Marshall (Canon) on Feb 14, 2025 at 04:07 UTC | |
by cavac (Prior) on Feb 17, 2025 at 15:14 UTC | |
by bonzi (Acolyte) on Feb 15, 2025 at 09:24 UTC | |
by Marshall (Canon) on Feb 15, 2025 at 20:58 UTC | |
|
Re: Socket read timeout on Windows
by haukex (Archbishop) on Feb 15, 2025 at 10:20 UTC |