POE::C...epalive(3pm)

πŸ“¦
version 0.2720 Β· 5 versions
, in debian bookworm, debian trixie, ubuntu noble, ubuntu resolute, ubuntu stonking

πŸ’– 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::ReadWrite objects 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::Keepalive object, 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 πŸ”₯

  • POE
  • POE::Component::Client::Keepalive
  • POE::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