lua-users home
lua-l archive

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

Hi all,

In short: How can I be notified of a new socket?
      Or: How can I enumerate all existing sockets
          which are read interested or write interested?

I need this in C, not Lua, for collecting sockets that
need to be polled in my own event loop.

Long version:

In my application, I run a main loop that polls and
handles various sockets or Windows' event objects.
I want to export this loop into Lua in such a way that
a Lua call to "some.loop()" sits in the loop and handles

Any new sockets that are created by the Lua-Socket package
also need to be polled by this loop. A server (listening/
accepting) socket as well as any accepted socket. All have
to be polled by my central loop along with other objects.

In an earlier version I patched luasocket to call a callback
whenever connect() or accept() or close() succeeded. This
worked well enough.

When upgrading to Lua-5.1.1, my goal is to no more link a
patched version of luasocket together with my application
and a patched lua.c to a standalone interpreter.

I'd rather rely on the package system, such that starting from
a plain standalone "lua" the user can <<require "ourstuff">>
and <<require "luasocket">>  and whatever else he requires.

Thanks for any help,

Dirk Zoller