[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: Re: LuaSocket - non-blocking connect ?
- From: Matthew Wild <mwild1@...>
- Date: Sat, 30 May 2009 11:16:22 +0100
On Sat, May 30, 2009 at 2:13 AM, Diego Nehab <email@example.com> wrote:
>>> 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.
> Yes. Select for writing. When select returns, call connect again on the
> socket to see if the connection succeeded. It should return the error
> "already connected".
It seems to me that connect() can block (30 seconds in my case) when
the DNS server for the domain is unreachable. I only discovered this
the other day and haven't managed to confirm the finding yet. If it's
true then it seems I need to switch DNS lookups for A records also to
our async DNS library...