lua-users home
lua-l archive

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

Hi all,

I do not plan to implement event-driven I/O in LuaSocket, at least not
in the near future. So, to solve the "wait-on-several-sockets" problem,
I would rather have a cleaner interface to select.

The library caches it's reads from sockets (thus achieving 10-20 fold
increase in the performance of line mode I/0), so that I have to check
if there is data available in socket buffers before calling select.
Because of that, I can't just export select and I am definitely not
exporting FD_* "macros".

I was thinking about a select that receives a table with the socket
objects to be queried and returns a table with those that pass the
query. The function call also receives a string describing the type of
query (receive or send) and an optional timeout value.

    a = s:accept(); b = s:accept(); c = s:accept()
    -- checks who is readable
    r = select({a, b, c}, "r", 2)

After the call, if only b and c were readable, r would equal {b,c} (or
{c,b}). Would everyone be happy with that? Maybe someone has a better