develooper Front page | perl.perl5.porters | Postings from April 2004

Re: [perl #29019] nonblocking read returns EAGAIN at eof

Thread Previous | Thread Next
Nicholas Clark
April 29, 2004 09:20
Re: [perl #29019] nonblocking read returns EAGAIN at eof
Message ID:
On Wed, Apr 21, 2004 at 03:46:43AM -0000, David Muir Sharnoff wrote:

> On a non-blocking socket when there is nothing more
> to read and the other side has closed the connection,
> read() returns undef and sets $! to EAGAIN.
> Unix behavior in this situation is to return zero byte
> and no error.

perl's read() is doing buffered IO, equivalent to C's fread()
Hence you're mixing buffered IO and non blocking file descriptors, which is

> I believe perl should follow the Unix behavior.  It's already
> hard enough to detect EOF on non-blocking sockets.

If you use sysread instead of read you shouldn't have a problem.

Nicholas Clark

Thread Previous | Thread Next Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at | Group listing | About