lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]

On 25-Jan-05, at 7:18 AM, David Burgess wrote:

Important note: a known bug in WinSock causes select to fail on
non-blocking TCP sockets. The function may return a socket as
writable even though the socket is not ready for sending.

This still true in "recent" Windowses, e.g. 2000 SP4, 2003, XP SP1/2?
If its the bug I know, yes.

Surely this is true in general? You could not in general guarantee that
a select()ed socket will not return EWOULDBLOCK unless you knew that
the socket was never read/written except following the select();
consequently, you should always be prepared for EWOULDBLOCK.

select() can only verify that the socket was ready to read (or write)
at the moment that it is called. Some other thread or process could
read from (or write to) the socket before the thread/process doing the
select gets around to it.

Of course, in the case of writing to a socket, it is also possible
that the remote end has closed the socket in between the select()
and the write; there are really very few guarantees.