lua-users home
lua-l archive

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


Den 2012-03-16 01:55, skrev Sam Roberts:
On Thu, Mar 15, 2012 at 3:59 PM, Jay Carlson<nop@nop.com>  wrote:
This is the most basic usage of the BSD socket API, and while not
directly supported by luasocket, you can do it like this:

https://github.com/sam-github/swirl/blob/master/lua/sockext.lua, see line 39.
This works because elsewhere sockets are set to have a timeout of 0.
Of course, if you don't set a timeout, you're going to block.


That is one of the things I don't like about LuaSockets: AFAIK there is no way from Lua to make the socket nonblocking. By nonblocking I mean in C "fcntl(socket_fd, F_SETFL, flags|O_NONBLOCK)". When I want a nonblocking socket, I want to say in Lua "sock:setnonblocking()", and it stays nonblocking.

The second thing is that all error codes should be returned so they can be dealt with.

Egil