[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: RE: flawed LuaSocket select()/tcp.receive() interaction ?
- From: "Jerome Vuarand" <jerome.vuarand@...>
- Date: Mon, 20 Nov 2006 11:27:18 -0500
> So, what do I need to do to handle this properly ? Is there a
> way to make tcp.receive() have the same behaviour as my
> libc's receive(), that is
> - don't receive any more then the requested amount of bytes from the
> socket, and leave the rest pending so select() will notice there's
> still data waiting to be read.
> - also return when fewer then the requested amount of bytes are
> received, returning both the data and it's size
According to the doc of receive in LuaSocket , you can pass "*a" as a
pattern to read all the data available in the socket. Also socket.select
 should tell if characters are available for reading, so it should
return any socket that has unread buffered data, even if no socket
actually received data (though there may be a bug somewhere).
Also if you want to read a specific maximum of bytes (eg. up to 8
bytes), you can set the socket to non blocking mode, and then read 8
bytes, and you may have a partial result available (still according to
receive doc  in such a case it should