lua-users home
lua-l archive

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


On Fri, May 29, 2009 at 2:41 PM, Francisco Sant'anna
<francisco.santanna@gmail.com> wrote:
> Is it possible?
>
> If I'm not missing something, a call to socket.connect will block the
> application until the connection is ok (or fail).
> The problem is that I want to use LuaSocket in an event-driven system --
> such connect call inside a callback would freeze the whole system.
> I would like something like:
> socket.connect(..., cb_function)
> Where cb_function receives the connection or nil when failing.

Doing socket.tcp(), setting it to non-blocking, then call connect(),
then selecting on it should work if I recall correctly.

Even if you don't want to use COPAS, it's code is short, and reading
it would give you some decent sample code.

Cheers,
Sam