.\" -*- mode: troff; coding: utf-8 -*- .\" Automatically generated by Pod::Man 5.01 (Pod::Simple 3.43) .\" .\" Standard preamble: .\" ======================================================================== .de Sp \" Vertical space (when we can't use .PP) .if t .sp .5v .if n .sp .. .de Vb \" Begin verbatim text .ft CW .nf .ne \\$1 .. .de Ve \" End verbatim text .ft R .fi .. .\" \*(C` and \*(C' are quotes in nroff, nothing in troff, for use with C<>. .ie n \{\ . ds C` "" . ds C' "" 'br\} .el\{\ . ds C` . ds C' 'br\} .\" .\" Escape single quotes in literal strings from groff's Unicode transform. .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" .\" If the F register is >0, we'll generate index entries on stderr for .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index .\" entries marked with X<> in POD. Of course, you'll have to process the .\" output yourself in some meaningful fashion. .\" .\" Avoid warning from groff about undefined register 'F'. .de IX .. .nr rF 0 .if \n(.g .if rF .nr rF 1 .if (\n(rF:(\n(.g==0)) \{\ . if \nF \{\ . de IX . tm Index:\\$1\t\\n%\t"\\$2" .. . if !\nF==2 \{\ . nr % 0 . nr F 2 . \} . \} .\} .rr rF .\" ======================================================================== .\" .IX Title "IO::Async::Protocol 3pm" .TH IO::Async::Protocol 3pm 2024-02-04 "perl v5.38.2" "User Contributed Perl Documentation" .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .if n .ad l .nh .SH NAME "IO::Async::Protocol" \- base class for transport\-based protocols .SH DESCRIPTION .IX Header "DESCRIPTION" This subclass of IO::Async:Notifier provides storage for a IO::Async::Handle object, to act as a transport for some protocol. It contains an instance of the transport object, which it adds as a child notifier, allowing a level of independence from the actual transport being used. For example, a stream may actually be an IO::Async::SSLStream to allow the protocol to be used over SSL. .PP This class is not intended to be used directly, instead, see one of the subclasses .IP "IO::Async::Protocol::Stream \- base class for stream-based protocols" 4 .IX Item "IO::Async::Protocol::Stream - base class for stream-based protocols" .SH EVENTS .IX Header "EVENTS" The following events are invoked, either using subclass methods or CODE references in parameters: .SS on_closed .IX Subsection "on_closed" Optional. Invoked when the transport handle becomes closed. .SH PARAMETERS .IX Header "PARAMETERS" The following named parameters may be passed to \f(CW\*(C`new\*(C'\fR or \f(CW\*(C`configure\*(C'\fR: .SS "transport => IO::Async::Handle" .IX Subsection "transport => IO::Async::Handle" The IO::Async::Handle to delegate communications to. .SS "on_closed => CODE" .IX Subsection "on_closed => CODE" CODE reference for the \f(CW\*(C`on_closed\*(C'\fR event. .PP When a new \f(CW\*(C`transport\*(C'\fR object is given, it will be configured by calling the \&\f(CW\*(C`setup_transport\*(C'\fR method, then added as a child notifier. If a different transport object was already configured, this will first be removed and deconfigured using the \f(CW\*(C`teardown_transport\*(C'\fR. .SH METHODS .IX Header "METHODS" .SS transport .IX Subsection "transport" .Vb 1 \& $transport = $protocol\->transport; .Ve .PP Returns the stored transport object .SS connect .IX Subsection "connect" .Vb 1 \& $protocol\->connect( %args ); .Ve .PP Sets up a connection to a peer, and configures the underlying \f(CW\*(C`transport\*(C'\fR for the Protocol. .PP Takes the following named arguments: .IP "socktype => STRING or INT" 8 .IX Item "socktype => STRING or INT" Required. Identifies the socket type, and the type of continuation that will be used. If this value is \f(CW"stream"\fR or \f(CW\*(C`SOCK_STREAM\*(C'\fR then \f(CW\*(C`on_stream\*(C'\fR continuation will be used; otherwise \f(CW\*(C`on_socket\*(C'\fR will be used. .IP "on_connected => CODE" 8 .IX Item "on_connected => CODE" Optional. If supplied, will be invoked once the connection has been established. .Sp .Vb 1 \& $on_connected\->( $protocol ); .Ve .IP "transport => IO::Async::Handle" 8 .IX Item "transport => IO::Async::Handle" Optional. If this is provided, it will immediately be configured as the transport (by calling \f(CW\*(C`configure\*(C'\fR), and the \f(CW\*(C`on_connected\*(C'\fR callback will be invoked. This is provided as a convenient shortcut. .PP Other arguments will be passed to the underlying IO::Async::Loop \f(CW\*(C`connect\*(C'\fR call. .SH "TRANSPORT DELEGATION" .IX Header "TRANSPORT DELEGATION" The following methods are delegated to the transport object .PP .Vb 1 \& close .Ve .SH "SUBCLASS METHODS" .IX Header "SUBCLASS METHODS" \&\f(CW\*(C`IO::Async::Protocol\*(C'\fR is a base class provided so that specific subclasses of it provide more specific behaviour. The base class provides a number of methods that subclasses may wish to override. .PP If a subclass implements any of these, be sure to invoke the superclass method at some point within the code. .SS setup_transport .IX Subsection "setup_transport" .Vb 1 \& $protocol\->setup_transport( $transport ); .Ve .PP Called by \f(CW\*(C`configure\*(C'\fR when a new \f(CW\*(C`transport\*(C'\fR object is given, this method should perform whatever setup is required to wire the new transport object into the protocol object; typically by setting up event handlers. .SS teardown_transport .IX Subsection "teardown_transport" .Vb 1 \& $protocol\->teardown_transport( $transport ); .Ve .PP The reverse of \f(CW\*(C`setup_transport\*(C'\fR; called by \f(CW\*(C`configure\*(C'\fR when a previously set-up transport object is about to be replaced. .SH AUTHOR .IX Header "AUTHOR" Paul Evans