[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: Re: LuaSocket, Win32 and select()
- From: Rici Lake <lua@...>
- Date: Thu, 27 Jan 2005 22:19:32 -0500
On 27-Jan-05, at 6:58 PM, Diego Nehab wrote:
It's not true in general. You would expect to be able to write
right after select returns telling you that you indeed can write
I can well believe that there are any number of flaws in the Windows
implementation. Nonetheless, I don't expect to able to write an
arbitrary something after select() informs me that the socket
is writable. send() is atomic; if it cannot send the entire message,
it either blocks or returns EWOULDBLOCK (or, if the message is too
big, it returns a different error). select() informs me that the
socket is writable if it has some room.  If I have more to send
than the room available, I would expect to receive EWOULDBLOCK and
I ought to be prepared for it.
Even if I were only sending one byte, I have no idea how much time
has passed between the select() returning and the send()
being called. If any other process has access to the same socket,
the socket may well be unwritable again.
If an implementation of send() returned EWOULDBLOCK because there
was some error condition, I *would* consider that to be broken.
However, in that case, I would also expect select() to inform me
that the socket was ready to write. 
Relevant quotes from Posix:
 If a descriptor refers to a socket, the implied output
function is the sendmsg() function supplying an amount of
normal data equal to the current value of the SO_SNDLOWAT
option for the socket.
 A descriptor shall be considered ready for writing when a
call to an output function with O_NONBLOCK clear would not block,
whether or not the function would transfer data successfully.