Dear monks,

problem is as follows: I use a combination of Socket and IO::Select, quite classic really. I open a number of socket connections using this little snippet:

sub makecon { my($self, $server, $port) = @_; my($iaddr, $paddr, $filehandle); my $proto = getprotobyname('tcp'); unless($iaddr = inet_aton($server)) { carp "No host found: $server"; + return; } $paddr = sockaddr_in($port, $iaddr); unless(socket($filehandle, PF_INET, SOCK_STREAM, $proto)) { carp "so +cket failure: $!"; return; } unless(connect($filehandle, $paddr)) { carp "connect failure: $!"; r +eturn; } return $filehandle; }
and then stuff the filehandle into IO::Select so I can perform the classic select loop to check which filehandles have data available. However, what I'm trying to do now is to implement a detection system for when a socket has died. Having read the documentation for IO::Select my first impression was that IO::Select->has_exception() would be the perfect tool to do so but for some reason it refuses to give me back anything, even though I am absolutely sure that the connection is dead on the other side. Any suggestions or ideas?


Remember rule one...

In reply to Knowing when a socket connection is dead by Forsaken

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • 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:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.