> Are you using read, readline (aka <>) or eof? Those aren't compatible with select. You need to use sysread.

Good point. Reminded me of this old node, an example of a complete event-driven Perl server using IO::Select. From its source code:

# ----------------------------------------------------------------- # Perl network programming notes # ------------------------------ # Reading can be done with: # 1) <$sock> - blocks till new line # 2) read($sock, $buf, $len) - blocks till $len bytes received # (like W Richard Stevens readn function + in C) # 3) sysread($sock, $buf, $len) - may return less than asked for # (like read()/recv() in C) # ------------------------------------------------------- ... # This one blocks until newline received. # $data = <$client>; # This one blocks till $len bytes received (like Stevens readn fun +ction in C) # my $hdr; # my $hdrlen = read( $client, $hdr, $SYSLOG_HDR_LEN ); # This one may return less than asked for (like read()/recv() in C) my $msglen = sysread( $client, $data, $SYSLOG_MAX_MSG_LEN );

Given the commenting out above, I presumably tried all three at the time before settling on sysread. :)


In reply to Re^2: IO::Select woes by eyepopslikeamosquito
in thread IO::Select woes by Anonymous Monk

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.