lua-users home
lua-l archive

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



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 something
right after select returns telling you that you indeed can write
something.

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. [1] 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. [2]

Relevant quotes from Posix:

[1] 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.

[2] 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.