POE::C...epalive(3pm)
π POE::C...epalive(3pm) β bestie edition π
okay so you're reading the POE::C...epalive(3pm) page (yes that's the manual name, it's abbreviated, we don't talk about it π). Sit down, grab a strawberry, and let's get into it.
β¨ NAME β¨
POE::Component::Connection::Keepalive β it's a wheel wrapper around a kept-alive socket. that's the whole vibe. a little cozy jacket for your socket. π§₯β¨
πΈ VERSION πΈ
version 0.272 β periodt.
π¦ SYNOPSIS π¦
bestie the real full working example lives over in the SYNOPSIS for POE::Component::Client::Keepalive, so go peek at that if you want the whole picture. but here's the lil taste:
my $connection = $response->{connection};
$heap->{connection} = $connection;
$connection->start( InputEvent => "got_input" );
delete $heap->{connection}; # When done with it.
likeβ¦ look at that. clean. iconic. delete when you're done and it handles itself. π
π DESCRIPTION π
POE::Component::Connection::Keepalive is a helper class for POE::Component::Client::Keepalive. it wraps managed sockets and gives them a few extra little features, like a glow-up but for filehandles. π
- Connection objects free their underlying sockets when they are
DESTROYed. so you literally do not have to explicitly free sockets when you're done with them. no cap. that chore? gone. π§Ήβ¨ - Connection objects manage
POE::Wheel::ReadWriteobjects internally, which saves you a bit of effort. lowkey a lifesaver.
π new
Creates a new POE::Component::Connection::Keepalive instance. it takes two parameters:
- a socket handle (
socket) - a reference to a
POE::Component::Client::Keepaliveobject, which manages the socket when the connection is destroyed (manager)
my $conn = POE::Component::Connection::Keepalive->new(
socket => $socket_handle,
manager => $poe_component_client_keepalive,
);
ngl, new() is usually called by a POE::Component::Client::Keepalive object, not by you. it's giving "let the adults handle it." π
π start
Starts a POE::Wheel::ReadWrite object. every parameter except Handle for start() gets passed directly to POE::Wheel::ReadWrite's constructor. Handle is provided by the connection object itself β it comes with its own, bestie, don't worry about it.
start() returns a reference to the new POE::Wheel::ReadWrite object, but honestly? you don't need 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. and the POE::Wheel::ReadWrite object will be DESTROYed when the connection object is. mutual destruction, but make it healthy. π
# 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};
}
see how handle_error just deletes it? that's the whole cleanup. chef's kiss. πβ¨
π wheel
Returns a reference to the internal POE::Wheel::ReadWrite object, so you can call methods on it. like, you want to poke the wheel directly? here's your poke pass.
$heap->{connection}->wheel()->pause_input();
obsessed with how short that is. π«Ά
π close
Closes the connection immediately. it also calls shutdown_input() and shutdown_output() on the wheel. boom, done, no lingering, no dramatic goodbye. πͺπ¨
π₯ SEE ALSO π₯
POEPOE::Component::Client::KeepalivePOE::Wheel::ReadWrite
go read those, they're the extended universe. iykyk. πβ¨
π BUGS π
None known. literally none. we love a flawless queen. π
πΈ 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. π
ok that's the whole page, you're fully caught up, go forth and keep those sockets alive bestie π β¨
and that's a wrap!! this was perl v5.34.0, dated 2022-06-18, from the POE::C...epalive(3pm) manual page β mwah, bye, ily π¦ππ
π¦ where this page comes from
- debian bookworm: libpoe-component-client-keepalive-perl 0.2720-3 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- debian trixie: libpoe-component-client-keepalive-perl 0.2720-3 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu noble: libpoe-component-client-keepalive-perl 0.2720-3 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu resolute: libpoe-component-client-keepalive-perl 0.2720-3 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu stonking: libpoe-component-client-keepalive-perl 0.2720-3 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms