On http://linux.die.net/man/2/select, under BUGS section it is mentioned that the select system call may sometimes spuriously set the FD ready and the subsequent read call will return 0. The text describes one such example (wrong checksum) but I am assuming there would be other reasons too (otherwise they would have fixed this).
Any ideas what could the other causes for Select to return a FD ready spuriously.
and does this apply to other OS'es also. I am currently asking about Linux.
Relevant Section for the link above:
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.
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…