Good point Errto, you drove me to dig out the Perl Cookbook recipe 7.23, which, to my horror, also does a sysread() of one character at a time (and with no performance caveat). I wonder if anyone has encapsulated a nice clean buffering scheme to work in harness with select() and sysread()? Update: quick look on CPAN found nothing, but Lincoln Stein's book "Network Programming with Perl" (Chapter 13) features an IO::Getline module that seems to be what I'm after, namely "line-oriented reading from sockets/handles with access to internal buffer".

One important point made in this recipe is that you must use unbuffered sysread() (and not the buffered I/O functions) with select() because select's response does not reflect user level buffering.

Update: Found this interesting bit of history from comp.lang.perl.moderated (15-Jan-1999) describing a mythical sysreadline() function requested by Larry but, alas, never implemented.


In reply to Re^4: unbuffered read from socket by eyepopslikeamosquito
in thread unbuffered read from socket 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.