If there is nothing to read,it means the sysread has finished all the reading, I should see something in the results? | [reply] |
x12345:
Not exactly--it can also mean "I haven't received a response yet". So you're probably terminating the loop before the other side ever had a chance to reply. (Considering the timing, you may be exiting before the other computer even received the request.)
Update: It can also mean "The network is really busy, so the next packet hasn't arrived yet." That could be a problem if you've received only part of your response.
...roboticus
When your only tool is a hammer, all problems look like your thumb.
| [reply] |
Could you show me how to change my code to get the results?
| [reply] |
my $buf;
while (1) {
my $rv = sysread($out, $buf, 64*1024, length($buf));
if (!defined($rv) && !$!{EAGAIN} && !$!{EWOULDBLOCK}) {
die $!;
}
if (defined($rv) && !$rv) {
last;
}
... whatever it is you wanted to do instead of blocking ...
}
print $buf;
| [reply] [d/l] [select] |
I found the problem in my loop, after use perl -d debugger, it is the $bytes_read should be "my $bytes_read", in the code, it is defined twice, it is a little bit confused, should have better clear way to do that, but in the code I have, it is like that, and when I rewrite the code, I remove my in frond $bytes_code in the while loop, which was wrong. So it should be
my $bytes_read = sysread($fh,$bug,$blocksize)
| [reply] [d/l] |