I m doing a sysread in Perl 5.8.2 on AIX 5.3. As per the documentation, sysread is supposed to give 0 when it has read all read from filehandle.
In my scenario, the filehandle is STDIN and points to a socket. So I m basically doing a sysread from a socket. But I never get 0 from sysread and it just blocks, even after client has sent all data.
Any idea what might be wrong?
Thanks.
What do you mean "sent all data"? sysread returns zero when the handle encounters an end-of-file condition, not when there's no more data available right now. For a socket, EOF on read occurs when the other side has shutdown the socket for write. (Well, and sysread will also return undef, which is numerically equal to zero, if an error occurs such as a network timeout.)
Check out the select command (the one with the 4 arguments). It can tell you
whether there is any input to be read on your filehandle.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With