Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl-Sensitive Sunglasses
 
PerlMonks  

Re: Sysread returning 0 when used with sockets

by mr_mischief (Monsignor)
on Mar 16, 2011 at 05:08 UTC ( [id://893495]=note: print w/replies, xml ) Need Help??


in reply to Sysread returning 0 when used with sockets

If you've read all that is written to a file, aren't you at the end of the file?

sysread returns undef if there's an error. Being at the end of the file is a normal condition, especially for a pipe or socket. You might find some information on sysread by looking at some docs for the underlying read(2) system call, such as this from the docs for it on my system:

RETURN VALUE

On success, the number of bytes read is returned (zero indicates end of file), and the file position is advanced by this number. It is not an error if this number is smaller than the number of bytes requested; this may happen for example because fewer bytes are actually available right now (maybe because we were close to end-of-file, or because we are reading from a pipe, or from a terminal), or because read() was interrupted by a signal. On error, -1 is returned, and errno is set appropriately. In this case it is left unspecified whether the file position (if any) changes.

On what, exactly, are you basing your time at which to read? Are you sure your timer and the timer on the server are set to the exact number of seconds and starting at the same time? If the server hasn't written new data yet, there won't be any new data to read yet.

  • Comment on Re: Sysread returning 0 when used with sockets

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://893495]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others chilling in the Monastery: (3)
As of 2024-04-25 19:53 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found