Okay - problem has been solved, and I also have a slight confession.

I actually edited down my program a bit more than I should have when I posted it, and it didn't reflect it's true functionality. When a new socket was opened, I was immediately reading data with a sysread. (the first block of data after an open socket is supposed to contain the filename for the server to write the following data to, so I always assumed the client would be a 'good' client and have that data read to be read on open!) The code was hanging on that particular sysread. Sometimes the client requests an open socket and does not send any data. Why the code would just hang on sysread baffles me, but that is exactly what it was doing. I did have the code to process successfully read data, zero data, and undefined return from sysread, but in this one special cases it would never break out of the sysread function. Why is that?

My pared down code - and yours, too - gave me the idea to just accept the socket request and put it on the select queue to wait for data to be read. Problem solved. I now wait for data before reading it, and it now handles good and bad clients.

Many thanks for the help, monks. I hope this in turn can help other who experience the same situation. Don't assume clients will behave!

p.s. I would be interested if anyone has insight why sysread hangs in this sort of scenario...thx!


In reply to Re^2: 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.