[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: LuaSocket - can I select on descriptors that are not socket objects?
- From: Diego Nehab <diego@...>
- Date: Wed, 4 Oct 2006 15:49:02 -0400 (EDT)
From diego@princeton.edu Wed Oct 4 15:46:02 2006
Date: Wed, 4 Oct 2006 15:45:58 -0400 (EDT)
From: Diego Nehab <diego@tecgraf.puc-rio.br>
To: Lua list <lua@bazar2.conectiva.com.br>
Subject: Re: LuaSocket - can I select on descriptors that are not socket objects?
Hi,
Sorry to break the thread, but my message bounced and I had
already erased the post. :/
- It looks like socket.select() only takes a socket object, but I would
like to select on other file descriptors. Will I need to create a
fd-wrapper object in order to do this?
Quick dirty undocumented solution: Unix just use a table
that has a getfd() and dirty() methods (check source code,
dirty() is to support input buffering). On Windows, this
won't work. Not my fault, though. Sockets are not file
descriptors on Windows and select() only works with sockets.
- It looks like tcp() can only create a new socket descriptor. If my lua
code is called from inetd, fd 0 will be a connected socket. It would
be nice to be able to call socket.tcp() with the descriptor of an
already connected socket.
Quick dirty undocumented solution: call setfd().
- Also, I would like to integrate socket.select() with io.popen(), I
guess I will need to add io:fileno() and either a generic fd-wrapper
socket object, or a socket.pipe() that takes a fd, or a socket.popen()
that takes args like io.popen().
On Unix, as long as you have the fd, you are all set.
[]s,
Diego.