I am working with some laboratory instruments that communicate either through bouilt-in HTTP server or low-level TCP. Both occasionally "freeze".
I create the socket thusly:
my $sock_Zona = IO::Socket::INET->new(
PeerAddr => $par{addr_Zona},
PeerPort => $par{port_Zona},
Proto => "tcp",
Type => SOCK_STREAM,
Timeout => $par{conn_tmo}
);
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:
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});
}
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.
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.