=encoding utf8 =head1 NAME IOMux::Net::TCP - handle a TCP connection =head1 INHERITANCE IOMux::Net::TCP is an IOMux::Handler::Read is an IOMux::Handler IOMux::Net::TCP is an IOMux::Handler::Write is an IOMux::Handler =head1 SYNOPSIS =head1 DESCRIPTION Handle a service or locally initiated TCP connection. Extends L<"DESCRIPTION" in IOMux::Handler::Write|IOMux::Handler::Write/"DESCRIPTION">. Extends L<"DESCRIPTION" in IOMux::Handler::Read|IOMux::Handler::Read/"DESCRIPTION">. =head1 METHODS Extends L<"METHODS" in IOMux::Handler::Write|IOMux::Handler::Write/"METHODS">. Extends L<"METHODS" in IOMux::Handler::Read|IOMux::Handler::Read/"METHODS">. =head2 Constructors Extends L<"Constructors" in IOMux::Handler::Write|IOMux::Handler::Write/"Constructors">. Extends L<"Constructors" in IOMux::Handler::Read|IOMux::Handler::Read/"Constructors">. =over 4 =item IOMux::Net::TCP-EB(%options) Build a connection as client or server. You may either pass an prepared C object or parameters to initiate one. All %options which start with capitals are passed to the socket creation. See L for those additional %options. -Option --Defined in --Default fh IOMux::Handler name IOMux::Handler 'tcp $host:$port' read_size IOMux::Handler::Read 32768 socket write_size IOMux::Handler::Write 4096 =over 2 =item fh => FILEHANDLE =item name => STRING =item read_size => INTEGER =item socket => IO::Socket::INET Provide a socket, either as object or the parameters to instantiate it. =item write_size => INTEGER =back 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'); =item IOMux::Net::TCP-EB($mode, $what, %options) Inherited, see L =item IOMux::Net::TCP-EB($mode, $what, %options) Inherited, see L =back =head2 Accessors Extends L<"Accessors" in IOMux::Handler::Write|IOMux::Handler::Write/"Accessors">. Extends L<"Accessors" in IOMux::Handler::Read|IOMux::Handler::Read/"Accessors">. =over 4 =item $obj-EB() Inherited, see L =item $obj-EB() Inherited, see L =item $obj-EB() Inherited, see L =item $obj-EB() Inherited, see L =item $obj-EB() Inherited, see L =item $obj-EB() Inherited, see L =item $obj-EB() Inherited, see L =item $obj-EB() Inherited, see L =item $obj-EB( [$integer] ) Inherited, see L =item $obj-EB() =item $obj-EB() Inherited, see L =item $obj-EB() Inherited, see L =item $obj-EB( [$integer] ) Inherited, see L =back =head2 User interface Extends L<"User interface" in IOMux::Handler::Write|IOMux::Handler::Write/"User interface">. Extends L<"User interface" in IOMux::Handler::Read|IOMux::Handler::Read/"User interface">. =head3 Connection Extends L<"Connection" in IOMux::Handler::Write|IOMux::Handler::Write/"Connection">. Extends L<"Connection" in IOMux::Handler::Read|IOMux::Handler::Read/"Connection">. =over 4 =item $obj-EB( [$callback] ) Inherited, see L =item $obj-EB( [$callback] ) Inherited, see L =item $obj-EB( <0|1|2> ) Shut down a socket for reading or writing or both. See the C Perl documentation for further details. 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. example: $conn->shutdown(1); =item $obj-EB( [$timeout] ) Inherited, see L =item $obj-EB( [$timeout] ) Inherited, see L =back =head3 Reading Extends L<"Reading" in IOMux::Handler::Read|IOMux::Handler::Read/"Reading">. =over 4 =item $obj-EB($callback) Inherited, see L =item $obj-EB($callback) Inherited, see L =back =head3 Writing Extends L<"Writing" in IOMux::Handler::Write|IOMux::Handler::Write/"Writing">. =over 4 =item $obj-EB(STRING|SCALAR|LIST|ARRAY) Inherited, see L =item $obj-EB($format, $params) Inherited, see L =item $obj-EB(STRING|SCALAR|LIST|ARRAY) Inherited, see L =item $obj-EB( SCALAR, [$more] ) Inherited, see L =back =head2 Multiplexer Extends L<"Multiplexer" in IOMux::Handler::Write|IOMux::Handler::Write/"Multiplexer">. Extends L<"Multiplexer" in IOMux::Handler::Read|IOMux::Handler::Read/"Multiplexer">. =head3 Connection Extends L<"Connection" in IOMux::Handler::Write|IOMux::Handler::Write/"Connection">. Extends L<"Connection" in IOMux::Handler::Read|IOMux::Handler::Read/"Connection">. =over 4 =item $obj-EB( $mux, [$handler] ) Inherited, see L =item $obj-EB( $mux, [$handler] ) Inherited, see L =item $obj-EB() Inherited, see L =item $obj-EB() Inherited, see L =item $obj-EB() Inherited, see L =item $obj-EB() Inherited, see L =back =head3 Reading Extends L<"Reading" in IOMux::Handler::Write|IOMux::Handler::Write/"Reading">. Extends L<"Reading" in IOMux::Handler::Read|IOMux::Handler::Read/"Reading">. =over 4 =item $obj-EB() For sockets, this does not nessecarily mean that the descriptor has been closed, as the other end of a socket could have used L to close just half of the socket, leaving us free to write data back down the still open half. example: 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 L callback will be called. sub muxEOF { my ($self, $ref_input) = @_; print $fh "Well, goodbye then!\n"; $self->shutdown(1); } =item $obj-EB($fileno) Inherited, see L =item $obj-EB($fileno) Inherited, see L =item $obj-EB($buffer) Inherited, see L =item $obj-EB($fileno) Inherited, see L =item $obj-EB($fileno) Inherited, see L =back =head3 Writing Extends L<"Writing" in IOMux::Handler::Write|IOMux::Handler::Write/"Writing">. Extends L<"Writing" in IOMux::Handler::Read|IOMux::Handler::Read/"Writing">. =over 4 =item $obj-EB() Inherited, see L =item $obj-EB() Inherited, see L =item $obj-EB($fileno) Inherited, see L =item $obj-EB($fileno) Inherited, see L =back =head3 Service Extends L<"Service" in IOMux::Handler::Write|IOMux::Handler::Write/"Service">. Extends L<"Service" in IOMux::Handler::Read|IOMux::Handler::Read/"Service">. =head2 Helpers Extends L<"Helpers" in IOMux::Handler::Write|IOMux::Handler::Write/"Helpers">. Extends L<"Helpers" in IOMux::Handler::Read|IOMux::Handler::Read/"Helpers">. =over 4 =item $obj-EB(HASH) =item IOMux::Net::TCP-EB(HASH) Inherited, see L =item $obj-EB(HASH) =item IOMux::Net::TCP-EB(HASH) Inherited, see L =item $obj-EB($state, $read, $write, $error) Inherited, see L =item $obj-EB($state, $read, $write, $error) Inherited, see L =item $obj-EB() Inherited, see L =item $obj-EB() Inherited, see L =back =head1 SEE ALSO This module is part of IOMux distribution version 1.01, built on January 15, 2020. Website: F =head1 LICENSE Copyrights 2011-2020 by [Mark Overmeer ]. 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 F