apr-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Robert Norris <...@cataclysm.cx>
Subject PATCH: Determine how many bytes are waiting to be read from a socket
Date Thu, 04 Mar 2004 22:51:50 GMT
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've added configure checks for sys/ioctl.h, to get ioctl() and
FIONREAD. These should exist on just about all Unix-ish systems. Just in
case it doesn't, I've added an alternative implementation that uses
recv() and MSG_PEEK. I assume recv() is available, because functions in
sendrecv.c assume this too.

Rob.

-- 
Robert Norris                                       GPG: 1024D/FC18E6C2
Email+Jabber: rob@cataclysm.cx                Web: http://cataclysm.cx/

Mime
View raw message