1POE::Component::ConnectUisoenr::CKoenetprailbiuvtee(d3P)POeEr:l:CDoomcpuomneenntta:t:iCoonnnection::Keepalive(3)
2
3
4

NAME

6       POE::Component::Connection::Keepalive - a wheel wrapper around a
7       kept-alive socket
8

VERSION

10       version 0.272
11

SYNOPSIS

13         See the SYNOPSIS for POE::Component::Client::Keepalive for a
14         complete working example.
15
16         my $connection = $response->{connection};
17         $heap->{connection} = $connection;
18
19         $connection->start( InputEvent => "got_input" );
20
21         delete $heap->{connection};  # When done with it.
22

DESCRIPTION

24       POE::Component::Connection::Keepalive is a helper class for
25       POE::Component::Client::Keepalive.  It wraps managed sockets, providing
26       a few extra features.
27
28       Connection objects free their underlying sockets when they are
29       DESTROYed.  This eliminates the need to explicitly free sockets when
30       you are done with them.
31
32       Connection objects manage POE::Wheel::ReadWrite objects internally,
33       saving a bit of effort.
34
35       new
36         Creates a new POE::Component::Connection::Keepalive instance.  It
37         accepts two parameters: A socket handle (socket) and a reference to a
38         POE::Component::Client::Keepalive object to manage the socket when
39         the connection is destroyed.
40
41           my $conn = POE::Component::Connection::Keepalive->new(
42             socket  => $socket_handle,
43             manager => $poe_component_client_keepalive,
44           );
45
46         new() is usually called by a POE::Component::Client::Keepalive
47         object.
48
49       start
50         Starts a POE::Wheel::ReadWrite object.  All parameters except Handle
51         for start() are passed directly to POE::Wheel::ReadWrite's
52         constructor.  Handle is provided by the connection object.  start()
53         returns a reference to the new POE::Wheel::ReadWrite object, but it
54         is not necessary to save a copy of that wheel.  The connection object
55         keeps a copy of the reference internally, so the wheel will persist
56         as long as the connection does.  The POE::Wheel::ReadWrite object
57         will be DESTROYed when the connection object is.
58
59           # Asynchronous connection from Client::Keepalive.
60           sub handle_connection {
61             my $connection_info = $_[ARG0];
62             $_[HEAP]->{connection} = $connection_info->{connection};
63
64             $heap->{connection}->start(
65               InputEvent => "got_input",
66               ErrorEvent => "got_error",
67             );
68           }
69
70           # Stop the connection (and the wheel) when an error occurs.
71           sub handle_error {
72             delete $_[HEAP]->{connection};
73           }
74
75       wheel
76         Returns a reference to the internal POE::Wheel::ReadWrite object, so
77         that methods may be called upon it.
78
79           $heap->{connection}->wheel()->pause_input();
80
81       close
82         Closes the connection immediately. Calls shutdown_input() and
83         shutdown_output() on the wheel also.
84

SEE ALSO

86       POE POE::Component::Client::Keepalive POE::Wheel::ReadWrite
87

BUGS

89       None known.
90

LICENSE

92       This distribution is copyright 2004-2009 by Rocco Caputo.  All rights
93       are reserved.  This distribution is free software; you may redistribute
94       it and/or modify it under the same terms as Perl itself.
95

AUTHOR

97       Rocco Caputo <rcaputo@cpan.org>
98
99       Special thanks to Rob Bloodgood.
100
101
102
103perl v5.34.0                      2022-P0O1E-:2:1Component::Connection::Keepalive(3)
Impressum