The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.

NAME

AnyEvent::Ident::Client - Simple asynchronous ident client

VERSION

version 0.08

SYNOPSIS

 use AnyEvent::Ident::Client;
 
 my $client = AnyEvent::Ident::Client->new( hostname => 127.0.0.1' );
 $client->ident($server_port, $client_port, sub {
   my($res) = @_; # isa AnyEvent::Client::Response 
   if($res->is_success)
   {
     print "user: ", $res->username, "\n";
     print "os:   ", $res->os, "\n";
   }
   else
   {
     warn "Ident error: " $res->error_type;
   }
 });

CONSTRUCTOR

 my $client = AnyEvent::Ident::Client->new(%args);

The constructor takes the following optional arguments:

hostname

default 127.0.0.1

The hostname to connect to.

port

default 113

The port to connect to.

on_error

default carp error

A callback subref to be called on error (either connection or transmission error). Passes the error string as the first argument to the callback.

response_close

default AnyEvent::Ident::Response

Bless the response object into the given class. This class SHOULD inherit from AnyEvent::Ident::Response, or at least mimic its interface. This allows you to define your own methods for the response class.

METHODS

ident

 $client->ident( $server_port, $client_port, $callback );

Send an ident request to the ident server with the given TCP port pair. The callback will be called when the response is returned from the server. Its only argument will be an instance of AnyEvent::Ident::Response.

On the first call to this method, a connection to the ident server is opened, and will remain open until close (see below) is called, or if the $client object falls out of scope.

close

 $client->close;

Close the connection to the ident server. Requests that are in progress will receive an error response with the type UNKNOWN-ERROR.

AUTHOR

Graham Ollis <plicease@cpan.org>

COPYRIGHT AND LICENSE

This software is copyright (c) 2013 by Graham Ollis.

This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.