AnyEvent::Whois::Raw - Non-blocking wrapper for Net::Whois::Raw
use AnyEvent::Whois::Raw; $Net::Whois::Raw::CHECK_FAIL = 1; whois 'google.com', timeout => 10, sub { my $data = shift; if ($data) { my $srv = shift; print "$data from $srv\n"; } elsif (! defined $data) { my $srv = shift; print "no information for domain on $srv found"; } else { my $reason = shift; print "whois error: $reason"; } };
This module provides non-blocking AnyEvent compatible wrapper for Net::Whois::Raw. It is not trivial to make non-blocking module from blocking one without full rewrite. This wrapper makes such attempt. To decide how ugly or beautiful this attempt implemented see source code of the module.
whois() and get_whois() by default
DOMAIN, SRV and WHICH_WHOIS are same as whois arguments from Net::Whois::Raw.
Available %PARAMS are:
Timeout for whois request in seconds
Same as prepare callback from AnyEvent::Socket. So you can bind socket to some ip:
whois 'google.com', on_prepare => sub { bind $_[0], AnyEvent::Socket::pack_sockaddr(0, AnyEvent::Socket::parse_ipv4($ip))); }, sub { my $info = shift; }
CB is a callback which will be called when request will be finished. On success callback arguments are whois text data and whois server used for request. On failed false value (not undef) and failed reason.
Same explanation.
Net::Whois::Raw, AnyEvent::HTTP, AnyEvent::Socket
Oleg G, <oleg@cpan.org>
Copyright (C) 2011 by Oleg G
This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself
To install AnyEvent::Whois::Raw, copy and paste the appropriate command in to your terminal.
cpanm
cpanm AnyEvent::Whois::Raw
CPAN shell
perl -MCPAN -e shell install AnyEvent::Whois::Raw
For more information on module installation, please visit the detailed CPAN module installation guide.