[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: Non-blocking dns queries
- From: Rob Kendrick <lua-l@...>
- Date: Mon, 19 Mar 2007 14:47:04 +0000
On Mon, 2007-03-19 at 23:31 +1200, Richard Warburton wrote:
> Can socket.dns.tohostname(address) in Lua Sockets be set not to block,
> so other unrelated connections are not forced to wait?
>
> Anyone come across this?
>
> Anyone have lua example code doing dns lookups that I could examine to
> create a coroutine that doesn't block?
They way I've done it in the past (in Lua 4) is to fork() and have
another process handle (blocking) DNS queries, and report back results
to the main process over a socket, which I select() on. This of course
assume UNIX.
(This could be better done entirely from C, 'cause you could use a
socketpair() or a UNIX domain socket, but I couldn't be bothered at the
time.)
B.