1IO::Async::Protocol(3)User Contributed Perl DocumentationIO::Async::Protocol(3)
2
3
4
6 "IO::Async::Protocol" - base class for transport-based protocols
7
9 This subclass of IO::Async:Notifier provides storage for a
10 IO::Async::Handle object, to act as a transport for some protocol. It
11 contains an instance of the transport object, which it adds as a child
12 notifier, allowing a level of independence from the actual transport
13 being used. For example, a stream may actually be an
14 IO::Async::SSLStream to allow the protocol to be used over SSL.
15
16 This class is not intended to be used directly, instead, see one of the
17 subclasses
18
19 IO::Async::Protocol::Stream - base class for stream-based protocols
20
22 The following events are invoked, either using subclass methods or CODE
23 references in parameters:
24
25 on_closed
26 Optional. Invoked when the transport handle becomes closed.
27
29 The following named parameters may be passed to "new" or "configure":
30
31 transport => IO::Async::Handle
32 The IO::Async::Handle to delegate communications to.
33
34 on_closed => CODE
35 CODE reference for the "on_closed" event.
36
37 When a new "transport" object is given, it will be configured by
38 calling the "setup_transport" method, then added as a child notifier.
39 If a different transport object was already configured, this will first
40 be removed and deconfigured using the "teardown_transport".
41
43 transport
44 $transport = $protocol->transport
45
46 Returns the stored transport object
47
48 connect
49 $protocol->connect( %args )
50
51 Sets up a connection to a peer, and configures the underlying
52 "transport" for the Protocol.
53
54 Takes the following named arguments:
55
56 socktype => STRING or INT
57 Required. Identifies the socket type, and the type of
58 continuation that will be used. If this value is "stream" or
59 "SOCK_STREAM" then "on_stream" continuation will be used;
60 otherwise "on_socket" will be used.
61
62 on_connected => CODE
63 Optional. If supplied, will be invoked once the connection has
64 been established.
65
66 $on_connected->( $protocol )
67
68 transport => IO::Async::Handle
69 Optional. If this is provided, it will immediately be
70 configured as the transport (by calling "configure"), and the
71 "on_connected" callback will be invoked. This is provided as a
72 convenient shortcut.
73
74 Other arguments will be passed to the underlying IO::Async::Loop
75 "connect" call.
76
78 The following methods are delegated to the transport object
79
80 close
81
83 "IO::Async::Protocol" is a base class provided so that specific
84 subclasses of it provide more specific behaviour. The base class
85 provides a number of methods that subclasses may wish to override.
86
87 If a subclass implements any of these, be sure to invoke the superclass
88 method at some point within the code.
89
90 setup_transport
91 $protocol->setup_transport( $transport )
92
93 Called by "configure" when a new "transport" object is given, this
94 method should perform whatever setup is required to wire the new
95 transport object into the protocol object; typically by setting up
96 event handlers.
97
98 teardown_transport
99 $protocol->teardown_transport( $transport )
100
101 The reverse of "setup_transport"; called by "configure" when a
102 previously set-up transport object is about to be replaced.
103
105 Paul Evans <leonerd@leonerd.org.uk>
106
107
108
109perl v5.36.0 2023-01-20 IO::Async::Protocol(3)