poe::component::connection::keepalive(3pm) [debian man page]
POE::Component::Connection::Keepalive(3pm) User Contributed Perl Documentation POE::Component::Connection::Keepalive(3pm)NAME
POE::Component::Connection::Keepalive - a wheel wrapper around a kept-alive socket
VERSION
version 0.271
SYNOPSIS
See the SYNOPSIS for POE::Component::Client::Keepalive for a
complete working example.
my $connection = $response->{connection};
$heap->{connection} = $connection;
$connection->start( InputEvent => "got_input" );
delete $heap->{connection}; # When done with it.
DESCRIPTION
POE::Component::Connection::Keepalive is a helper class for POE::Component::Client::Keepalive. It wraps managed sockets, providing a few
extra features.
Connection objects free their underlying sockets when they are DESTROYed. This eliminates the need to explicitly free sockets when you are
done with them.
Connection objects manage POE::Wheel::ReadWrite objects internally, saving a bit of effort.
new
Creates a new POE::Component::Connection::Keepalive instance. It accepts two parameters: A socket handle (socket) and a reference to a
POE::Component::Client::Keepalive object to manage the socket when the connection is destroyed.
my $conn = POE::Component::Connection::Keepalive->new(
socket => $socket_handle,
manager => $poe_component_client_keepalive,
);
new() is usually called by a POE::Component::Client::Keepalive object.
start
Starts a POE::Wheel::ReadWrite object. All parameters except Handle for start() are passed directly to POE::Wheel::ReadWrite's
constructor. Handle is provided by the connection object. start() returns a reference to the new POE::Wheel::ReadWrite object, but it
is not necessary to save a copy of that wheel. The connection object keeps a copy of the reference internally, so the wheel will persist
as long as the connection does. The POE::Wheel::ReadWrite object will be DESTROYed when the connection object is.
# Asynchronous connection from Client::Keepalive.
sub handle_connection {
my $connection_info = $_[ARG0];
$_[HEAP]->{connection} = $connection_info->{connection};
$heap->{connection}->start(
InputEvent => "got_input",
ErrorEvent => "got_error",
);
}
# Stop the connection (and the wheel) when an error occurs.
sub handle_error {
delete $_[HEAP]->{connection};
}
wheel
Returns a reference to the internal POE::Wheel::ReadWrite object, so that methods may be called upon it.
$heap->{connection}->wheel()->pause_input();
close
Closes the connection immediately. Calls shutdown_input() and shutdown_output() on the wheel also.
SEE ALSO
POE POE::Component::Client::Keepalive POE::Wheel::ReadWrite
BUGS
None known.
LICENSE
This distribution is copyright 2004-2009 by Rocco Caputo. All rights are reserved. This distribution is free software; you may
redistribute it and/or modify it under the same terms as Perl itself.
AUTHOR
Rocco Caputo <rcaputo@cpan.org>
Special thanks to Rob Bloodgood.
perl v5.14.2 2012-05-15 POE::Component::Connection::Keepalive(3pm)
Check Out this Related Man Page
IKC::Channel(3pm) User Contributed Perl Documentation IKC::Channel(3pm)NAME
POE::Component::IKC::Channel - POE Inter-Kernel Communication I/O session
SYNOPSIS
use POE;
use POE::Component::IKC::Channel;
create_ikc_channel($handle, $name, $on_connect, $subscribe,
$rname, $unix);
DESCRIPTION
This module implements an POE IKC I/O. When a new connection is established, "IKC::Server" and "IKC::Client" create an "IKC::Channel" to
handle the I/O.
IKC communication happens in 2 phases : negociation phase and normal phase.
The negociation phase uses "Filter::Line" and is used to exchange various parameters between kernels (example : kernel names, what type of
freeze/thaw to use, etc). After negociation, "IKC::Channel" switches to a "Filter::Reference" and creates a "IKC::Responder", if needed.
After this, the channel forwards reads and writes between "Wheel::ReadWrite" and the Responder.
"IKC::Channel" is also in charge of cleaning up kernel names when the foreign kernel disconnects.
EXPORTED FUNCTIONS
create_ikc_channel
This function initiates all the work of connecting to a IKC connection channel. It is a wrapper around "spawn".
METHODS
spawn
POE::Component::IKC::Channel->spawn(%param);
Creates a new IKC channel to handle the negociations then the actual data.
Parameters are keyed as follows:
handle
The perl handle we should hand to "Wheel::ReadWrite::new".
kernel_name
The name of the local kernel. This is a stop-gap until event naming has been resolved.
on_connect
Code ref that is called when the negociation phase has terminated. Normaly, you would use this to start the sessions that post events
to foreign kernels.
subscribe
Array ref of specifiers (either foreign sessions, or foreign states) that you want to subscribe to. $on_connect will only be called if
you can subscribe to all those specifiers. If it can't, it will die().
unix
A flag indicating that the handle is a Unix domain socket or not.
aliases
Arrayref of aliases for the local kernel.
serializers
Arrayref or scalar of the packages that you want to use for data serialization. A serializer package requires 2 functions : freeze (or
nfreeze) and thaw. See "POE::Component::IKC::Client".
"protocol"
Which IKC negociation protocol to use. The original protocol ("IKC") was synchronous and slow. The new protocol ("IKC0") sends all
information at once. IKC0 will degrade gracefully to IKC, if the client and server don't match.
Default currently IKC but will move to IKC0 when I'm confident in the new protocol.
EVENTS
shutdown
This event causes the server to close it's socket and skiddadle on down the road. Normally it is only posted from IKC::Responder.
If you want to post this event yourself, you can get the channel's session ID from IKC::Client's on_connect:
POE::Component::IKC::Client->spawn(
....
on_connect=>sub {
$heap->{channel} = $poe_kernel->get_active_session()->ID;
},
....
);
Then, when it becomes time to disconnect:
$poe_kernel->call($heap->{channel} => 'shutdown');
Yes, this is a hack. A cleaner machanism needs to be provided.
BUGS AUTHOR
Philip Gwyn, <perl-ikc at pied.nu>
COPYRIGHT AND LICENSE
Copyright 1999-2011 by Philip Gwyn. All rights reserved.
This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
See <http://www.perl.com/language/misc/Artistic.html>
SEE ALSO
POE, POE::Component::IKC::Server, POE::Component::IKC::Client, POE::Component::IKC::Responder
perl v5.12.4 2011-08-27 IKC::Channel(3pm)