lua-users home
lua-l archive

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


On 01/07/15 14:33, Thijs Schreijer wrote:
I was thinking code preparing a file handle for serving with luasocket.
There seems to be some weird dancing involved with creating a connected
socket, replacing its fd, then invalidating something setting a fd of
-1, etc.

LuaSec does this, but its result is still a handle for a socket. But it has some magic in setting the fd and invalidating the original.

Now I get it, the invalidating is done to the keep the original socket from closing the migrated fd. OTOH, as you mention LuaSec does not need to deal with files (and it has a C component, so they could sneak a fileno() binding if needed).

Very useful example anyway, thanks.