MediocreGopher has asked for the wisdom of the Perl Monks concerning the following question:
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)?
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Getting sysread to read the full packet
by almut (Canon) on May 12, 2010 at 07:25 UTC | |
|
Re: Getting sysread to read the full packet
by ikegami (Patriarch) on May 12, 2010 at 13:32 UTC | |
|
Re: Getting sysread to read the full packet
by MediocreGopher (Initiate) on May 12, 2010 at 17:26 UTC |