in reply to Re^2: Net::DNS::Resolver and very slow reply
in thread Net::DNS::Resolver and very slow reply

mmm, okay.
Well, just for the sake of the exercise, I re-wrote your script and simplified it a bit. I also changed it so that it would take a domain name to test from the command line. Here is my version:
#!/usr/bin/perl -w use strict; use Net::DNS; my $domain = shift or die "Please supply a domain to query\n"; my @ips = resolve($domain); my $i; for (@ips) { print ++$i . ": $_\n"; } sub resolve { my $domain = shift; my $res = Net::DNS::Resolver->new; my $query = $res->search($domain); my @results; if ($query) { foreach my $rr ($query->answer) { next if $rr->type ne "A"; push @results, $rr->address . " (record type " . $rr->type + . ")"; } return @results; } else { return $res->errorstring; } }

I get similar results with this as I did with your original, but perhaps you can try this and see if it makes any difference. Some sample output:

time perl resolver.pl cnn.com 1: 64.236.24.12 (record type A) 2: 64.236.24.20 (record type A) 3: 64.236.24.28 (record type A) 4: 64.236.29.120 (record type A) 5: 64.236.16.20 (record type A) 6: 64.236.16.52 (record type A) 7: 64.236.16.84 (record type A) 8: 64.236.16.116 (record type A) real 0m0.562s user 0m0.320s sys 0m0.010s

As you can see, still quite fast. I also tried it on a windoze box and it returns just as quickly.

Hope this helps somewhat,
Darren :)

Replies are listed 'Best First'.
Re^4: Net::DNS::Resolver and very slow reply
by mellin (Scribe) on Sep 04, 2006 at 14:37 UTC

    McDarren, rewritten by you it works very quickly now! Like really_quickly. Thank you very much :)

    I Think i have to examine my version a little more closer once i get back to home, since there must be something very much wrong with it. How else could there be this much of a speed difference.

    Once again, thank you for rewriting this. Now i can move on with the actual program ;)