1POE::Component::ConnectUisoenr::CKoenetprailbiuvtee(d3P)POeEr:l:CDoomcpuomneenntta:t:iCoonnnection::Keepalive(3)
2
3
4
6 POE::Component::Connection::Keepalive - a wheel wrapper around a
7 kept-alive socket
8
10 See the SYNOPSIS for POE::Component::Client::Keepalive for a
11 complete working example.
12
13 my $connection = $response->{connection};
14 $heap->{connection} = $connection;
15
16 $connection->start( InputEvent => "got_input" );
17
18 delete $heap->{connection}; # When done with it.
19
21 POE::Component::Connection::Keepalive is a helper class for
22 POE::Component::Client::Keepalive. It wraps managed sockets, providing
23 a few extra features.
24
25 Connection objects free their underlying sockets when they are
26 DESTROYed. This eliminates the need to explicitly free sockets when
27 you are done with them.
28
29 Connection objects manage POE::Wheel::ReadWrite objects internally,
30 saving a bit of effort.
31
32 new
33 Creates a new POE::Component::Connection::Keepalive instance. It
34 accepts two parameters: A socket handle (socket) and a reference to a
35 POE::Component::Client::Keepalive object to manage the socket when
36 the connection is destroyed.
37
38 my $conn = POE::Component::Connection::Keepalive->new(
39 socket => $socket_handle,
40 manager => $poe_component_client_keepalive,
41 );
42
43 new() is usually called by a POE::Component::Client::Keepalive
44 object.
45
46 start
47 Starts a POE::Wheel::ReadWrite object. All parameters except Handle
48 for start() are passed directly to POE::Wheel::ReadWrite's
49 constructor. Handle is provided by the connection object. start()
50 returns a reference to the new POE::Wheel::ReadWrite object, but it
51 is not necessary to save a copy of that wheel. The connection object
52 keeps a copy of the reference internally, so the wheel will persist
53 as long as the connection does. The POE::Wheel::ReadWrite object
54 will be DESTROYed when the connection object is.
55
56 # Asynchronous connection from Client::Keepalive.
57 sub handle_connection {
58 my $connection_info = $_[ARG0];
59 $_[HEAP]->{connection} = $connection_info->{connection};
60
61 $heap->{connection}->start(
62 InputEvent => "got_input",
63 ErrorEvent => "got_error",
64 );
65 }
66
67 # Stop the connection (and the wheel) when an error occurs.
68 sub handle_error {
69 delete $_[HEAP]->{connection};
70 }
71
72 wheel
73 Returns a reference to the internal POE::Wheel::ReadWrite object, so
74 that methods may be called upon it.
75
76 $heap->{connection}->wheel()->pause_input();
77
78 close
79 Closes the connection immediately. Calls shutdown_input() and
80 shutdown_output() on the wheel also.
81
82 SEE ALSO
83 POE POE::Component::Client::Keepalive POE::Wheel::ReadWrite
84
86 None known.
87
89 This distribution is copyright 2004-2009 by Rocco Caputo. All rights
90 are reserved. This distribution is free software; you may redistribute
91 it and/or modify it under the same terms as Perl itself.
92
94 Rocco Caputo <rcaputo@cpan.org>
95
96 Special thanks to Rob Bloodgood.
97
99 Hey! The above document had some coding errors, which are explained
100 below:
101
102 Around line 187:
103 '=item' outside of any '=over'
104
105 Around line 193:
106 You forgot a '=back' before '=head1'
107
108
109
110perl v5.12.0 2009-P1O0E-:1:8Component::Connection::Keepalive(3)