AnyEvent-Whois-Raw
view release on metacpan or search on metacpan
lib/AnyEvent/Whois/Raw.pm view on Meta::CPAN
local $stash = $stash_ref;
$stash->{calls}{whois_query} = 0;
my $i = push @{$stash->{results}{whois_query}}, undef;
$stash->{errors}{whois_query}[$i-1] = "Connection to $srv failed: $!";
$stash->{caller}->(@{$stash->{args}});
return;
}
my @lines;
my $handle;
my $timer = AnyEvent->timer(
after => exists $stash_ref->{params}{timeout} ?
$stash_ref->{params}{timeout} :
$Net::Whois::Raw::TIMEOUT||30,
cb => sub {
if ($handle && !$handle->destroyed) {
$handle->destroy();
local $stash = $stash_ref;
$stash->{calls}{whois_query} = 0;
my $i = push @{$stash->{results}{whois_query}}, undef;
$stash->{errors}{whois_query}[$i-1] = "Connection to $srv timed out";
lib/AnyEvent/Whois/Raw.pm view on Meta::CPAN
fh => $fh,
on_read => sub {
my @l = split /(?<=\n)/, $_[0]->{rbuf};
if (@lines && substr($lines[-1], -1) ne "\n") {
$lines[-1] .= shift(@l);
}
push @lines, @l;
$_[0]->{rbuf} = '';
},
on_error => sub {
undef $timer;
$handle->destroy();
local $stash = $stash_ref;
$stash->{calls}{whois_query} = 0;
my $i = push @{$stash->{results}{whois_query}}, undef;
$stash->{errors}{whois_query}[$i-1] = "Read error from $srv: $!";
$stash->{caller}->(@{$stash->{args}});
},
on_eof => sub {
undef $timer;
local $stash = $stash_ref;
$handle->destroy();
$stash->{calls}{whois_query} = 0;
push @{$stash->{results}{whois_query}}, \@lines;
$stash->{caller}->(@{$stash->{args}});
}
);
$handle->push_write($whoisquery."\015\012");
}, sub {
( run in 1.392 second using v1.01-cache-2.11-cpan-49f99fa48dc )