Matthew Berk <[EMAIL PROTECTED]> writes: > In using LWP to gather pages, is there a way to shortcut the DNS > lookup to eliminate the overhead? I assume LWP leaves this to the OS, > in which case, my question is better asked elsewhere, yes?
LWP will let IO::Socket::INET module do the host lookup. This module will call the $self->_get_addr() method which by default will call gethostbyname() to get the information from the OS. You can provide your own implementation of _get_addr if you want it to do something else. You might for instance provide one that does more agressive caching or even one that does proper timeout handling. The following trivial program demonstrate how you can trap these calls. Regards, Gisle #!/usr/bin/perl -w use LWP::UserAgent; my $ua = LWP::UserAgent->new; print $ua->get("http://www.example.com/")->status_line, "\n"; print $ua->get("http://www.perl.org/")->status_line, "\n"; BEGIN { package Net::HTTP; use Socket qw(inet_ntoa); # demonstrate how we can trap host name lookups sub _get_addr { my $self = shift; my @addr = $self->SUPER::_get_addr(@_); print "_get_addr @_ => ", join(" ", map inet_ntoa($_), @addr), "\n"; return @addr; } }