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

NAME

Sprocket::Connection - Encapsulates a client or server connection

ABSTRACT

This module provides accessors and methods to handle Sprocket connections.

NOTES

Connection objects are created by Sprocket::Server and Sprocket::Client and passed to Sprocket::Plugin events.

METHODS

event( $event_name )

Returns an event name suitable for use with Sprocket witch pairs the event with the connection.

send( $data )

Send data to the connected peer. This is the same as a POE::Wheel put()

write( $data )

Same as send, whichever you prefer.

alarm_set( $event, $epoch_time, @etc )

See POE::Kernel. $event is passed through event() for you. Returns the alarm id.

alarm_adjust( $alarm_id, $seconds )

See POE::Kernel. Adjust an alarm by id.

alarm_remove( $alarm_id )

See POE::Kernel. Removes an alarm by id.

alarm_remove_all()

See POE::Kernel. Removes all alarms set for this connection.

delay_set( $event, $seconds_hence, @etc )

See POE::Kernel. Returns a delay id. $event is passed through event() for you.

delay_adjust( $delay_id, $seconds )

See POE::Kernel.

yield( $event, @etc )

Yield to an event in the same plugin.

call( $event, @etc )

Call an event in the same plugin.

post( $session, $event, @etc )

Shortcut to $poe_kernel->post().

accept()

Accept a connection during the accept phase.

reject()

Reject a connection during the accept phase.

close( $force )

Close a connection after all data is flushed, unless $force is defined then the connection is closed immediately.

reconnect()

Reconnect to the same destination.

get_driver_out_octets()

Returns the number of octets that haven't been written to the peer connection. See POE::Wheel::ReadWrite.

active()

Update the connection's active time to keep it from timing out. (If a timeout is set)

callback( $event, @etc )

Returns a callback tied to this connection. $event is passed through event() for you. Extra params (@etc) are optional.

postback( $event, @etc )

Returns a postback tied to this connection. $event is passed through event() for you. Extra params (@etc) are optional.

time_out( $seconds )

Set the idle disconnect time. Set to undef to disable.

ACCESSORS

filter

Returns the input/output filter. Normally a POE::Filter::Stackable object.

filter_in

Returns the input filter. Only use this if your plugin does not use the default filter: POE::Filter::Stackable

filter_out

Returns the output filter. Only use this if your plugin does not use the default filter: POE::Filter::Stackable

wheel

Returns the POE::Wheel::ReadWrite wheel for this connection.

connected

Returns true if this connection is connected.

error

A dualvar containing the error number and error string ONLY after an error has occurred.

active_time

The last time this conneciton was active.

create_time

The time this connection was created.

peer_ip

The peer ip for this connection.

peer_ips

Returns an array ref of peer ips for this connection. Only for client connections. If a hostname was used during a connect and that hostname resolved to multiple 'A' records, then they are retreivable here after a remote_connected event.

peer_port

The peer's port for this connection.

peer_addr

Combination of peer_ip:peer_port.

peer_hostname

Peer hostname for this connection (could be an IP).

local_ip

Local ip for this connection.

local_port

Local port for this connection.

state

Current or last conneciton state name. One of the Sprocket::Plugin event method names.

ID

The connection's ID. The connection object stringifies to Sprocket::Connection/$ID

x

A hash ref stash for plugins to store information, to avoid polluting $con's own hash ref. Easily used like so: $con->x->{foo}

SEE ALSO

POE, Sprocket, Sprocket::Plugin, Sprocket::Server, Sprocket::Client

AUTHOR

David Davis <xantus@cpan.org>

COPYRIGHT AND LICENSE

Copyright 2006-2007 by David Davis

See Sprocket for license information.