The London Perl and Raku Workshop takes place on 26th Oct 2024. If your company depends on Perl, please consider sponsoring and/or attending.

NAME

Sprocket::Client - The Sprocket Client

SYNOPSIS

    use Sprocket qw( Client );
    
    Sprocket::Client->spawn(
        Name => 'My Client',      # Optional, defaults to Client
        ClientList => [           # Optional
            '127.0.0.1:9979',
        ],
        Plugins => [
            {
                plugin => MyPlugin->new(),
                priority => 0, # default
            },
        ],
        LogLevel => 4,
    );

DESCRIPTION

Sprocket::Client defines a TCP/IP Client, initiates a TCP/IP connection with a server on a given IP and Port

METHODS

spawn( %options )

Create a new Sprocket::Client object.

Name => (str)

The Name for this server. This is used for logging. It is optional and defaults to 'Client'

ClientList => (array ref)

A list of one or more servers to connect to.

LogLevel => (int)

The minimum level of logging, defaults to 4.

Logger => (object)

Sprocket::Logger::Basic is the default and logs to STDERR. The object must support put( $server, { v => $level, msg => $msg } ) or wrap a logging system using this format.

Plugins => (array ref of hash refs)

Plugins that this client will hand off processing to. In an array ref of hash refs format as so:

    {
        plugin => MyPlugin->new(),
        priority => 0 # default
    }
MaxConnections => (int)

Sprocket will set the rlimit to this value using BSD::Resource

connect( $address, $port ) or connect( "$address:$port" )

Connect to a remote host.

get_connection( $id )

Retrieves a connection by its id.

shutdown( $type )

Shutdown this client. If $type is 'soft' then soft shutdown procedure will begin. remote_shutdown will be called for each connection.

ACCESSORS

name

The name of the client, specified during spawn.

session_id

Session id of the controlling poe session.

uuid

UUID of the client, generated during spawn.

shutting_down

returns the shutdown type, ie. 'soft' if shutting down, otherwize, undef.

connections

returns the number of connections

_logger

returns the logger object

opts

returns a hash ref of the options passed to spawn

EVENTS

These events are handled by plugins. See Sprocket::Plugin.

remote_accept
remote_connected
remote_receive
remote_disconnected
remote_connect_error
remote_time_out
remote_shutdown

HOOKS

See Sprocket for observer hook semantics.

sprocket.remote.connection.accept
sprocket.remote.connection.reject
sprocket.remote.connection.receive
sprocket.remote.address.resolved
sprocket.remote.wheel.error

SEE ALSO

POE, Sprocket, Sprocket::Connection, Sprocket::Plugin, Sprocket::Server, Sprocket::Server::PreFork, Sprocket::Server::UNIX, Sprocket::Logger::Basic, Sprocket::Logger::Log4perl

AUTHOR

David Davis <xantus@cpan.org>

RATING

Please rate this module. http://cpanratings.perl.org/rate/?distribution=Sprocket

COPYRIGHT AND LICENSE

Copyright 2006-2007 by David Davis

See Sprocket for license information.