-
-
15 Dec 2021 22:57:24 UTC
- Distribution: IO-Async
- Module version: 0.801
- Source (raw)
- Browse (raw)
- Changes
- How to Contribute
- Issues (61)
- Testers (1395 / 109 / 0)
- Kwalitee
Bus factor: 1- 82.09% Coverage
- License: perl_5
- Perl: v5.8.4
- Activity
24 month- Tools
- Download (247.35KB)
- MetaCPAN Explorer
- Permissions
- Subscribe to distribution
- Permalinks
- This version
- Latest version
- Dependencies
- Exporter
- File::stat
- Future
- Future::Utils
- IO::Poll
- List::Util
- Socket
- Storable
- Struct::Dumb
- Time::HiRes
- and possibly others
- Reverse dependencies
- CPAN Testers List
- Dependency graph
NAME
IO::Async::Protocol
- base class for transport-based protocolsDESCRIPTION
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.
This class is not intended to be used directly, instead, see one of the subclasses
- IO::Async::Protocol::Stream - base class for stream-based protocols
EVENTS
The following events are invoked, either using subclass methods or CODE references in parameters:
on_closed
Optional. Invoked when the transport handle becomes closed.
PARAMETERS
The following named parameters may be passed to
new
orconfigure
:transport => IO::Async::Handle
The IO::Async::Handle to delegate communications to.
on_closed => CODE
CODE reference for the
on_closed
event.When a new
transport
object is given, it will be configured by calling thesetup_transport
method, then added as a child notifier. If a different transport object was already configured, this will first be removed and deconfigured using theteardown_transport
.METHODS
transport
$transport = $protocol->transport
Returns the stored transport object
connect
$protocol->connect( %args )
Sets up a connection to a peer, and configures the underlying
transport
for the Protocol.Takes the following named arguments:
- socktype => STRING or INT
-
Required. Identifies the socket type, and the type of continuation that will be used. If this value is
"stream"
orSOCK_STREAM
thenon_stream
continuation will be used; otherwiseon_socket
will be used. - on_connected => CODE
-
Optional. If supplied, will be invoked once the connection has been established.
$on_connected->( $protocol )
- transport => IO::Async::Handle
-
Optional. If this is provided, it will immediately be configured as the transport (by calling
configure
), and theon_connected
callback will be invoked. This is provided as a convenient shortcut.
Other arguments will be passed to the underlying IO::Async::Loop
connect
call.TRANSPORT DELEGATION
The following methods are delegated to the transport object
close
SUBCLASS METHODS
IO::Async::Protocol
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.If a subclass implements any of these, be sure to invoke the superclass method at some point within the code.
setup_transport
$protocol->setup_transport( $transport )
Called by
configure
when a newtransport
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.teardown_transport
$protocol->teardown_transport( $transport )
The reverse of
setup_transport
; called byconfigure
when a previously set-up transport object is about to be replaced.AUTHOR
Paul Evans <leonerd@leonerd.org.uk>
Module Install Instructions
To install IO::Async, copy and paste the appropriate command in to your terminal.
cpanm IO::Async
perl -MCPAN -e shell install IO::Async
For more information on module installation, please visit the detailed CPAN module installation guide.