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
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |