lua-users home
lua-l archive

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


Implementing DNS lookups is far from trivial. You have to handle too many cases, such as:

- retry the query with a different DNS server if the DNS server you contacted does not do recursive lookups
- retry the query with a different DNS server if the DNS server you contacted times out
- retry the query using TCP if the reply that came back was truncated because of UDP size limits
- ....

Mozilla's DNS code is at http://lxr.mozilla.org/seamonkey/source/netwerk/dns/src/

You probably don't want to go there. I'd write a Lua extension that runs a number of OS threads to do lookups in parallel before I'd try to do host lookup myself.


On Mar 19, 2007, at 7:31 AM, 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?

Cheers.




--
Gé Weijers