[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: Re: LuaSocket - non-blocking connect ? (fwd)
- From: Matthew Wild <mwild1@...>
- Date: Mon, 1 Jun 2009 02:16:21 +0100
On Mon, Jun 1, 2009 at 1:59 AM, Diego Nehab <email@example.com> wrote:
>>> Yes, the DNS lookup can do that. What does an async DNS
>>> library look like?
>> It's a non-blocking wrapper around a fixed and hacked up version
>> of dns.lua. A nice C replacement regularly features in our
>> dreams :)
>> The catch is that we need to look up SRV records and need a reasonable
>> timeout, which the standard Linux resolver doesn't appear capable of.
> So there is a Lua implementation of gethostbyname that does
> not block?
Essentially yes, though it is a lot more powerful than gethostbyname().
>>> It seems as though you should have no
>>> trouble replacing the DNS lookup in LuaSocket with something
>>> else, without any changes to C code.
>> Oh so the DNS lookup is performed from inside LuaSocket? That greatly
>> simplifies things, thanks.
> I don't know what you mean by the question. LuaSocket has
> two DNS facilities. One is when you invoke
> socket.dns.toip(). The other is when you invoke connect()
> with a domain name. Both cases and up invoking
Sorry, I was thinking that it was connect() which accepted the
unresolved hostname, my mistake of course :)
> What I meant is that if you have a Lua replacement of
> gethostbyname, you can do your own translation and pass the
> ip as a string to the non-blocking connect().
It would obviously have to function as a wrapper around the existing
connect()... the existing connect() would be called in a callback when
the DNS response arrives.
But this is certainly possible.