NAME
AnyEvent::Whois::Raw - Non-blocking wrapper for Net::Whois::Raw
SYNOPSIS
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";
}
};
DESCRIPTION
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.
IMPORT
whois() and get_whois() by default
Net::Whois::Raw compatibilities and incompatibilities
- All global $Net::Whois::Raw::* options could be specified to change the behavior
- User defined functions such as *Net::Whois::Raw::whois_query_sockparams and others will not affect anything
- In contrast with Net::Whois::Raw whois and get_whois from this module will never die. On error first parameter of the callback will be false and second will contain error reason
FUNCTIONS
whois DOMAIN [, SRV [, WHICH_WHOIS] [, %PARAMS]], CB
DOMAIN, SRV and WHICH_WHOIS are same as whois arguments from Net::Whois::Raw.
Available %PARAMS are:
- timeout => $seconds
-
Timeout for whois request in seconds
- on_prepare => $cb
-
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.
get_whois DOMAIN [, SRV [, WHICH_WHOIS] [, %PARAMS]], CB
Same explanation.
NOTICE
- This module uses AnyEvent::HTTP for http queries, so you should tune $AnyEvent::HTTP::MAX_PER_HOST to proper value yourself.
- You should not load Net::Whois::Raw in your code if you are using this module, because this will cause incorrect work of the module.
SEE ALSO
Net::Whois::Raw, AnyEvent::HTTP, AnyEvent::Socket
AUTHOR
Oleg G, <oleg@cpan.org>
COPYRIGHT AND LICENSE
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