Asynchronous Resolving


The standard UNIX resolver is synchronous, which means it blocks the calling program until the name has been resolved. You make the call, the library issues the DNS query, and any other queries to configured name services such as NIS wait for the reply and then return to your program. This can lead to your application being blocked for several seconds. Depending on the application, this might or might not be acceptable. Under UNIX, though, it's not too hard to find a way around this restriction and implement non-blocking DNS. Some applications, such as Netscape, fork a separate process to perform resolving and use simple IPC mechanisms to communicate with it. Under various flavors of UNIX, the ways to accomplish this with processes, threads, message queues, pipes, shared memory, and semaphores are endless. But of course, you also can use a library that provides asynchronous name lookups .

Several such libraries are available under various licenses. I have not personally programmed with any of these libraries, so apply liberal amounts of your own discretion.

The Perl Net::DNS module is capable of supporting asynchronous requests. See the section "The Net::DNS Module" earlier in this chapter for more information.

GNU adns

GNU adns , written by Ian Jackson and Tony Finch, is in beta as of May 2000. Its authors describe it as "Advanced, easy to use, asynchronous-capable DNS client library and utilities." It not only provides asynchronous DNS , but it also extends beyond the capabilities of the standard UNIX resolver to provide access to all different record types and things such as the TTL of the returned record.

The library home page is at http://www.chiark.greenend.org.uk/~ian/adns/. It is available for FTP from its home site at ftp://ftp.chiark.greenend.org.uk/users/ian/adns/ and also from GNU FTP archives, such as ftp://ftp.gnu.org/gnu/adns/. It is licensed under the GNU GPL and (with some restrictions) the LGPL. These licenses might or might not be compatible with the software you are developing, depending on your licensing. Please read the COPYING file in the distribution carefully if you're not familiar with the GPL and LGPL.

The library is not currently documented except in its header file.

arlib

arlib is part of the BIND contrib bundle, so if you have a complete BIND tar ball, you'll find it there. If not, you will find it at the ISC FTP site (see Chapters 2 and 15). It was designed to be simple so as to attract few bugs and has succeeded in that respect. Because it was written in 1992, it has hardly been maintained; Darren Reed, the author, reports that there have been "no bugs to maintain."

The library is freely available, but you must ask the author for permission to distribute it as part of anything you develop. Reed reports that he has never said no to anyone, but expressly forbids its use in GPLed software. You will find his email address in the software.

In the way of documentation, the bundle includes a pretty complete code sample illustrating its use.

DNScache Library

D.J. Bernstein, the man behind the well-known MTA qmail, has also committed DNScache a recursive DNS cache server. It includes a resolver library suitable for use in asynchronous resolver implementations. The facilities are basic but perhaps good enough. The DNScache home page is at http://cr.yp.to/dnscache.html , and the software is available from there.



The Concise Guide to DNS and BIND
The Concise Guide to DNS and BIND
ISBN: 0789722739
EAN: 2147483647
Year: 1999
Pages: 183

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net