
IOMux::Net::TCP - handle a TCP connection

IOMux::Net::TCP is a IOMux::Handler::Read is a IOMux::Handler IOMux::Net::TCP is a IOMux::Handler::Write is a IOMux::Handler IOMux::Net::TCP is extended by IOMux::HTTP

Handle a service or locally initiated TCP connection.

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.
-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'
, Reuse => 1
);
my $client = IOMux::Net::TCP->new
( socket => $socket
);
$mux->add($client);
# short form
my $client = IOMux::Net::TCP->new
( PeerAddr => 'www.example.com:80'
, Reuse => 1
);
$mux->add($client);
# even shorter
my $client = $mux->open('tcp'
, PeerAddr => 'www.example.com:80'
, Reuse => 1
);
Shut down a socket for reading or writing or both. See the shutdown 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);
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.
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 mux_close callback will be called.
sub mux_eof
{ my ($self, $ref_input) = @_;
print $fh "Well, goodbye then!\n";
$self->shutdown(1);
}

This module is part of IOMux distribution version 0.12, built on January 27, 2011. Website: http://perl.overmeer.net/ All modules in this suite: "Any::Daemon", "IOMux", and "IOMux::HTTP".
Please post questions or ideas to perl@overmeer.net

Copyrights 2011 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 http://www.perl.com/perl/misc/Artistic.html