I'm using the Socket module to read data from http servers. I can connect to them and write requests to them successfully, but receiving the answers to those requests has proven to be challenging. Basically I have sysread read from the socket until it doesn't have anything to read using the following loop:

do {$bytes_read = sysread(DST,$data,1024,length($data));} while ($byte +s_read == 1024);

which I "borrowed" from another thread here on perlmonks. The problem I'm facing (I believe) is that the server isn't dishing out information fast enough; sysread gets info, sticks it onto $data, and comes back to the socket before the server can get more information to the socket. Sysread then finds an empty socket and the loop ends prematurely. Does anyone have any tricks for dealing with this (or am I completely wrong and the problem is my own stupidity)?


In reply to Getting sysread to read the full packet by MediocreGopher

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.