On Fri, 30 Mar 2012, Tomalak Geret'kal wrote:
Ohai
Our approach is pretty simple... a `select` call followed
by a `read` call, in a loop. The socket is a blocking
socket.
Intermittently, though, (say every 3-8 hours) on a
particular device, we're seeing `select` return >0 then
`read` return 0. Allegedly this non-error condition
implies an orderly shutdown on the remote end.
Might this be a case of (from select(2) man page, section
BUGS)?:
"Under Linux, select() may report a socket file descriptor
as "ready for
reading", while nevertheless a subsequent read blocks.
This could for
example happen when data has arrived but upon
examination has wrong
checksum and is discarded. There may be other
circumstances in which a
file descriptor is spuriously reported as ready. Thus it
may be safer
to use O_NONBLOCK on sockets that should not block."
Cheers,
Håkan