Do you know where your variables are? | |
PerlMonks |
Sysread returning 0 when used with socketsby Zubinix (Acolyte) |
on Mar 16, 2011 at 04:01 UTC ( [id://893490]=perlquestion: print w/replies, xml ) | Need Help?? |
Zubinix has asked for the wisdom of the Perl Monks concerning the following question:
Hi all monks! I am having trouble using sysread with a standard INET soocket created using IO::Socket::INET. I am trying to read data from a server that sends data in chunks about 1 minute apart then optionally after receiving a chunk of data I might want to send something back to the server. Hence I need to use a sysread with a timeout. However, my problem is that though I can receive the first block of data, the second block of data which arrives after a minute results in sysread returning 0 which I believe indicates EOF (socket closed?). The results is the same if I use IO::Select or an alarm construct such as:
On reading the second block of data sysread will exit immediately and always return 0. If I don't implement any mechanism to break out of the sysread (including using select statements) then sysread work fine and is able to read subsequent data blocks sent from the server but it does block while doing this which is not what I want. Any ideas on how to make sysread work in this situation in a non-blocking manner? Thanks!
Back to
Seekers of Perl Wisdom
|
|