IOMux::Net::TCP - handle a TCP connection
IOMux::Net::TCP is an IOMux::Handler::Read is an IOMux::Handler IOMux::Net::TCP is an IOMux::Handler::Write is an IOMux::Handler
Handle a service or locally initiated TCP connection.
Extends "DESCRIPTION" in IOMux::Handler::Write.
Extends "DESCRIPTION" in IOMux::Handler::Read.
Extends "METHODS" in IOMux::Handler::Write.
Extends "METHODS" in IOMux::Handler::Read.
Extends "Constructors" in IOMux::Handler::Write.
Extends "Constructors" in IOMux::Handler::Read.
Build a connection as client or server. You may either pass an prepared socket object or parameters to initiate one. All %options which start with capitals are passed to the socket creation. See extractSocket() for those additional %options.
socket
-Option --Defined in --Default fh IOMux::Handler <required> name IOMux::Handler 'tcp $host:$port' read_size IOMux::Handler::Read 32768 socket <required> write_size IOMux::Handler::Write 4096
Provide a socket, either as object or the parameters to instantiate it.
example:
# long form, most flexible my $socket = IO::Socket::INET->new(PeerAddr => 'www.example.com:80'); my $client = IOMux::Net::TCP->new(socket => $socket); $mux->add($client); # short form my $client = IOMux::Net::TCP->new(PeerAddr => 'www.example.com:80'); $mux->add($client); # even shorter my $client = $mux->open('tcp', PeerAddr => 'www.example.com:80');
Inherited, see "Constructors" in IOMux::Handler
Extends "Accessors" in IOMux::Handler::Write.
Extends "Accessors" in IOMux::Handler::Read.
Inherited, see "Accessors" in IOMux::Handler
Inherited, see "Accessors" in IOMux::Handler::Read
Inherited, see "Accessors" in IOMux::Handler::Write
Extends "User interface" in IOMux::Handler::Write.
Extends "User interface" in IOMux::Handler::Read.
Extends "Connection" in IOMux::Handler::Write.
Extends "Connection" in IOMux::Handler::Read.
Inherited, see "Connection" in IOMux::Handler
Shut down a socket for reading or writing or both. See the shutdown Perl documentation for further details.
shutdown
If the shutdown is for reading (0 or 2), it happens immediately. However, shutdowns for writing (1 or 2) are delayed until any pending output has been successfully written to the socket.
$conn->shutdown(1);
Extends "Reading" in IOMux::Handler::Read.
Inherited, see "Reading" in IOMux::Handler::Read
Extends "Writing" in IOMux::Handler::Write.
Inherited, see "Writing" in IOMux::Handler::Write
Extends "Multiplexer" in IOMux::Handler::Write.
Extends "Multiplexer" in IOMux::Handler::Read.
Extends "Reading" in IOMux::Handler::Write.
For sockets, this does not nessecarily mean that the descriptor has been closed, as the other end of a socket could have used shutdown() to close just half of the socket, leaving us free to write data back down the still open half.
In this example, we send a final reply to the other end of the socket, and then shut it down for writing. Since it is also shut down for reading (implicly by the EOF condition), it will be closed once the output has been sent, after which the close() callback will be called.
sub muxEOF { my ($self, $ref_input) = @_; print $fh "Well, goodbye then!\n"; $self->shutdown(1); }
Inherited, see "Reading" in IOMux::Handler
Extends "Writing" in IOMux::Handler::Read.
Inherited, see "Writing" in IOMux::Handler
Extends "Service" in IOMux::Handler::Write.
Extends "Service" in IOMux::Handler::Read.
Extends "Helpers" in IOMux::Handler::Write.
Extends "Helpers" in IOMux::Handler::Read.
Inherited, see "Helpers" in IOMux::Handler
This module is part of IOMux distribution version 1.01, built on January 15, 2020. Website: http://perl.overmeer.net/CPAN
Copyrights 2011-2020 by [Mark Overmeer <markov@cpan.org>]. For other contributors see ChangeLog.
This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself. See http://dev.perl.org/licenses/
To install IOMux, copy and paste the appropriate command in to your terminal.
cpanm
cpanm IOMux
CPAN shell
perl -MCPAN -e shell install IOMux
For more information on module installation, please visit the detailed CPAN module installation guide.