apr-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Scott Lamb <sl...@slamb.org>
Subject Re: PATCH: Determine how many bytes are waiting to be read from a socket
Date Fri, 05 Mar 2004 00:04:05 GMT

On Mar 4, 2004, at 4:51 PM, Robert Norris wrote:

> Attached is a patch that adds a function apr_socket_pending(). This
> allows the caller to find out how many bytes are waiting to be read 
> from
> a socket without actually reading those bytes.
>
> I use this to determine if the peer has closed the connection. In that
> case, the socket goes readable, and this function reports 0 bytes
> waiting.

I don't think this is correct. select() and similar functions can 
return spuriously, at least on some platforms[*]. I would imagine this 
would return 0 in such a case, and the socket would not have closed. 
Why not just do the read and see if it returns 0?

[*] - http://cr.yp.to/docs/unixport.html

Scott


Mime
View raw message