Heya - thanks for the responses! First, this is on Ubuntu Linux - sorry for not including that. Perl v5.10.0 I've update the code according to your suggestion:
while (1) { # Set up bit vectors for polling my $rin = ''; my $ein = ''; my $rout; my $eout; vec ($rin, fileno ($sock) , 1) = 1; vec ($ein, fileno ($sock) , 1) = 1; foreach my $streamID (keys %openStreamsSock) { vec ($fin, fileno($openStreamsSock{$streamID}) , 1) = 1; vec ($ein, fileno($openStreamsSock{$streamID}) , 1) = 1; } # Wait for incoming message my $nfound = select ($rout=$rin, undef, $eout=$ein, 5); if ($nfound) { # Check client streams, close any in error foreach my $streamID (keys %openStreamsSock) { if (vec($eout, fileno($openStreamsSock{$streamID}),1)) { close ($openStreamsSock{$streamID}); delete ($openStreamsSock{$streamID}); } } if (vec($rout, fileno($sock),1)) { $openStreamsSock{$streamRequest++} = $sock->accept(); } else { foreach my $streamID (keys %openStreamsSock) { if (vec($rout, fileno($openStreamsSock{$streamID}),1)) { # read data off the socket; not a message here, just r +aw data $msgSize = sysread ($openStreamsSock{$streamID}, $msgReceived, 1048576); if (defined ($msgSize) && ($msgSize > 0)) { writeStreamData ($streamID, $msgReceived); } else { # $msgSize being 0 indicates end of stream, or # $msgSize being undef indicates error, so close close ($openStreamsSock{$streamID}); delete ($openStreamsSock{$streamID}); } } } } } else { print "$0: Normal timeout of select...\n"; } }
Unfortunately, this doesn't seem to change the behavior in any way. I hope I'm using it correctly. What really gets me is that the timeout also stops functioning. It leads me to suspect the code got stuck somewhere else in the script. All indications from my debug statements (removed for readability) showed the script going all the way back to the select statement and then never coming back, but I can't be absolutely sure. If anyone else has ideas, I'm all ears. (uh, eyes)

In reply to Re^4: socket select hangs after client restarts by planetjeff
in thread socket select hangs after client restarts by planetjeff

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.