NAME

POE::Stage::Resolver - a fake non-blocking DNS resolver

SYNOPSIS

# Note, this is not a complete program.
# See the distribution's examples directory.

$self->{req}{resolver} = POE::Stage::Resolver->new(
	method      => "resolve",
	on_success  => "handle_host",
	on_error    => "handle_error",
	args        => {
		input     => "thirdlobe.com",
		type      => "A",   # A is default
		class     => "IN",  # IN is default
	},
);

sub handle_host {
	my ($self, $args) = @_;

	my $input  = $args->{input};
	my $packet = $args->{packet};

	my @answers = $packet->answer();
	foreach my $answer (@answers) {
		print(
			"Resolved: $input = type(", $answer->type(), ") data(",
			$answer->rdatastr, ")\n"
		);
	}

	delete $self->{req}{resolver};
}

DESCRIPTION

POE::Stage::Resolver is a simple non-blocking DNS resolver. It uses Net::DNS::Resolver for the bulk of its work. It returns Net::DNS::Packet objects in its "success" responses. Making heads or tails of them will require perusal of Net::DNS's documentation.

PUBLIC COMMANDS

Commands are invoked with POE::Request objects.

new (input => INPUT, type => TYPE, class => CLASS)

Creates a POE::Stage::Resolver instance and asks it to resolve some INPUT into records of a given CLASS and TYPE. CLASS and TYPE default to "IN" and "A", respectively.

When complete, the stage will return either a "success" or an "error".

PUBLIC RESPONSES

Responses are returned by POE::Request->return() or emit().

"success" (input, packet)

Net::DNS::Resolver successfully resolved a request. The original input is passed back in the "input" parameter. The resulting Net::DNS::Packet object is returned in "packet".

"error" (input, error)

Net::DNS::Resolver, or something else, failed to resolve the input to a response. The original input is passed back in the "input" parameter. Net::DNS::Resolver's error message comes back as "error".

BUGS

See http://thirdlobe.com/projects/poe-stage/report/1 for known issues. See http://thirdlobe.com/projects/poe-stage/newticket to report one.

SEE ALSO

POE::Stage and POE::Request. The examples/log-resolver.perl program in POE::Stage's distribution. Net::DNS::Packet for an explanation of returned packets. POE::Component::Client::DNS for the original inspiration.

AUTHORS

Rocco Caputo <rcaputo@cpan.org>.

LICENSE

POE::Stage::Resolver is Copyright 2005 by Rocco Caputo. All rights are reserved. You may use, modify, and/or distribute this module under the same terms as Perl itself.