NAME

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

SYNOPSIS

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

        sub some_handler :Handler {
                my $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 :Handler {
                my ($arg_input, $arg_packet);

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

                # Cancel the resolver by destroying it.
                my $req_resolver = undef;
        }

DESCRIPTION

POE::Stage::Resolver is a simple non-blocking DNS resolver. For now it uses Net::DNS::Resolver for the bulk of its work. It returns Net::DNS::Packet objects in its "success" responses. Please see the documentation for Net::DNS.

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 respond with either a "success" or an "error" message.

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.

POE::Stage is too young for production use. For example, its syntax is still changing. You probably know what you don't like, or what you need that isn't included, so consider fixing or adding that, or at least discussing it with the people on POE's mailing list or IRC channel. Your feedback and contributions will bring POE::Stage closer to usability. We appreciate it.

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 and a much more complete asynchronous DNS implementation.

AUTHORS

Rocco Caputo <rcaputo@cpan.org>.

LICENSE

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