AnyEvent-Connection

 view release on metacpan or  search on metacpan

README  view on Meta::CPAN

NAME
    AnyEvent::Connection - Base class for tcp connectful clients

SYNOPSIS
        package MyTCPClient;
        use base 'AnyEvent::Connection';

        package main;
        my $client = MyTCPClient->new(
        host => 'localhost',
        port => 12345,
        );
        $client->reg_cb(
        connected => sub {
            my ($client,$connection,$host,$port) = @_;
            # ...
            $client->after(
            $interval, sub {
                # Called after interval, if connection still alive
            }
            );
        }
        connfail = sub {
            my ($client,$reason) = @_;
            # ...
        },
        disconnect => sub {
            my ($client,$reason) = @_;
        },
        error => sub {
            my ($client,$error) = @_;
            # Called in error conditions for callbackless methods
        },
        );
        $client->connect;

EVENTS
    connected ($connobject, $host, $port)
        Called when client get connected.

    connfail
        Called, when client fails to connect

    disconnect
        Called whenever client disconnects

    error
        Called in error conditions for callbackless methods (for ex: when
        calling push_write on non-connected client)

OPTIONS
    host
        Host to connect to

    port
        Port to connect to

    timeout [ = 3 ]
        Connect/read/write timeout in seconds

    reconnect [ = 1 ]
        If true, automatically reconnect after disconnect/connfail after
        delay $reconnect seconds

    rawcon [ = AnyEvent::Connection::Raw ]
        Class that implements low-level connection

OPERATION METHODS
    new Cleates connection object (see OPTIONS)

    connect
        Begin connection

    disconnect ($reason)
        Close current connection. reason is optional

    reconnect
        Close current connection and establish a new one



( run in 0.669 second using v1.01-cache-2.11-cpan-df04353d9ac )