Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:

When using gethostbyaddr it is super fast if the address matches a server name. It is super slow if it does not match. Is there a way of setting the timeout for the gethostbyaddr call?? Thanks....dostie@nettaxi.com

Replies are listed 'Best First'.
Re: Hurry up Gethost
by tinman (Curate) on Mar 24, 2001 at 02:00 UTC

    I'd suggest Net::DNS over gethostbyaddr.. From the man pages of Net::DNS::Resolver that I was able to locate off Google,
    tcp_timeout can be used to set the timeout for queries, the default being 120 sec

    After using gethostbyaddr for a reporting/log file analysis tool that I wrote not too long ago, I might even suggest a locally cached copy of addresses.. this made a significant difference in the speed of the app for subsequent invocations..

    HTH

Re: Hurry up Gethost
by tadman (Prior) on Mar 24, 2001 at 04:41 UTC
    Net::DNS is a better tool if resolving is causing a lot of problems. It allows better user control over how the resolver works.

    If you're an admin on a UNIX-type system, you can tweak your resolver to make it work better. The defaults are really lax and can cause problems like you have encountered. As a bonus, this will speed up everything on the system that uses DNS.

    For Linux, BSD, and the like, /etc/resolv.conf is used to control the behaviour of the resolver. There are some parameters such as timeout which can speed things up for failed results, and you can use more than one DNS server using the rotate option.

    More details at: man resolv.conf