Looking at the question, i would first think that the addition of select() is about the only way to get around this.
But, in thinking, when writting to a closed socket, a PIPE signal will be generated. In the event of a PIPE signal, it can be checked by either installing a handler, or ignoring the signal. Such as :
# method one
$SIG{PIPE} = sub { $SERVER_DISCONNECT = 1; };
#
# when printing to socket, check $SERVER_DISCONNECT
# and handle if ($SERVER_DISCONNECT == 1)
# method two (Posix systems only)
$SIG{PIPE} = 'IGNORE';
use Errno ':POSIX';
# other code here
unless (print SOCKET "$data") {
if ($! == EPIPE) {
# pipe error, attempt reconnection to server
} else {
# real error
}
}
More Info :Network Programming with Perl (ISBN: 0-201-61571-1)
and the she says, "well, this ones eating my popcorn"
- Matt-Fu (MZSanford)
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.