I want to use AnyEvent::DNS to resolve my domain on some DNS servers. The server list are got from two place, each about 60+ servers. When I run resolve for only one serverlist,no problem.But if I run resolve for all list, I got an error: "unable to create either an IPv4 or an IPv6 socket".
My script as follow: use AnyEvent::DNS; use AnyEvent::Socket; use AnyEvent; use Module::Runtime qw/require_module/; use lib './lib'; my $domain = $ARGV[0] // 'fmn.xnimg.cn'; my $cv = AnyEvent->condvar; for my $mod ( ( 'DNS::xixik', 'DNS::yqie' ) ) { #for my $mod ( ( 'DNS::xixik' )) { require_module($mod); my $dnslist = $mod->new->get_dnslist; for my $isp ( keys %$dnslist ) { while ( my ( $addr, $dns ) = each %{ $dnslist->{$isp} } ) { resolv( $isp . $addr, $_, $domain ) for @{$dns}; } } } $cv->recv; sub resolv { my ( $addr, $dns, $domain ) = @_; my $resolver = AnyEvent::DNS->new( server => [ AnyEvent::Socket::parse_address $dns ], ); $cv->begin; $resolver->resolve( "$domain" => 'a', sub { my @ips = map { $_->[-1] } @_; printf "%s (%s) => %s\n", $dns, $addr, join( ", ", @ips ) if @ips; $cv->end; } ); }