lua-users home
lua-l archive

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

On Tue, Nov 11, 2008 at 3:23 PM, Diego Nehab <> wrote:
>>> Please check the thread at
>> This is officially a FAQ, why not add it to the docs?
> Because if I added it to the docs, I would say it can't be
> done and it's not supported. :/

It is "supported". You personally take time to explain how to do it,
over and over again! :-) You can't usually get that kind of support
even when you pay.

Anyhow, luasocket has a nice API, and has a nice select interface and
buffer reading interface (other than how unobvious it is to just read
whatever data is available).

But you can't get much done if you can't add your own descriptors to
its select loop. Assignment #1 in my first OS course long ago was to
write a simple talk implementation, selecting on stdin and a socket
descriptor. Its pretty much the simplest of socket programming
examples, but you can't implement this with luasocket's documented

There isn't a "supported" way to get the fd, either, to allow you to
add a luasocket object to your own application's event/select loop.

>> Diego - I read through the buffer code... still no idea what dirty() is
>> for.
> The dirty() method
> tells me when not to bother with a socket.

Great, so I guess my sockext lib is doing the following right, by
always returning false.


Return an object that can be used with to select on an
arbitrary file descriptor.
function selectable(fd)
  fd = assert(tonumber(fd), "fd must be a number")
  local s = { fd = fd }
  function s:getfd() return fd end
  function s:dirty() return false end
  return s