NAME

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

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

SYNOPSIS

DESCRIPTION

Handle a service or locally initiated TCP connection.

Extends "DESCRIPTION" in IOMux::Handler::Write.

Extends "DESCRIPTION" in IOMux::Handler::Read.

METHODS

Extends "METHODS" in IOMux::Handler::Write.

Extends "METHODS" in IOMux::Handler::Read.

Constructors

Extends "Constructors" in IOMux::Handler::Write.

Extends "Constructors" in IOMux::Handler::Read.

IOMux::Net::TCP->new(%options)

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
fh => FILEHANDLE
name => STRING
read_size => INTEGER
socket => IO::Socket::INET

Provide a socket, either as object or the parameters to instantiate it.

write_size => INTEGER

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');
IOMux::Net::TCP->open($mode, $what, %options)

Inherited, see "Constructors" in IOMux::Handler

IOMux::Net::TCP->open($mode, $what, %options)

Inherited, see "Constructors" in IOMux::Handler

Accessors

Extends "Accessors" in IOMux::Handler::Write.

Extends "Accessors" in IOMux::Handler::Read.

$obj->fh()

Inherited, see "Accessors" in IOMux::Handler

$obj->fh()

Inherited, see "Accessors" in IOMux::Handler

$obj->fileno()

Inherited, see "Accessors" in IOMux::Handler

$obj->fileno()

Inherited, see "Accessors" in IOMux::Handler

$obj->mux()

Inherited, see "Accessors" in IOMux::Handler

$obj->mux()

Inherited, see "Accessors" in IOMux::Handler

$obj->name()

Inherited, see "Accessors" in IOMux::Handler

$obj->name()

Inherited, see "Accessors" in IOMux::Handler

$obj->readSize( [$integer] )

Inherited, see "Accessors" in IOMux::Handler::Read

$obj->socket()
$obj->usesSSL()

Inherited, see "Accessors" in IOMux::Handler

$obj->usesSSL()

Inherited, see "Accessors" in IOMux::Handler

$obj->writeSize( [$integer] )

Inherited, see "Accessors" in IOMux::Handler::Write

User interface

Extends "User interface" in IOMux::Handler::Write.

Extends "User interface" in IOMux::Handler::Read.

Connection

Extends "Connection" in IOMux::Handler::Write.

Extends "Connection" in IOMux::Handler::Read.

$obj->close( [$callback] )

Inherited, see "Connection" in IOMux::Handler

$obj->close( [$callback] )

Inherited, see "Connection" in IOMux::Handler

$obj->shutdown( <0|1|2> )

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);
$obj->timeout( [$timeout] )

Inherited, see "Connection" in IOMux::Handler

$obj->timeout( [$timeout] )

Inherited, see "Connection" in IOMux::Handler

Reading

Extends "Reading" in IOMux::Handler::Read.

$obj->readline($callback)

Inherited, see "Reading" in IOMux::Handler::Read

$obj->slurp($callback)

Inherited, see "Reading" in IOMux::Handler::Read

Writing

Extends "Writing" in IOMux::Handler::Write.

$obj->print(STRING|SCALAR|LIST|ARRAY)

Inherited, see "Writing" in IOMux::Handler::Write

$obj->printf($format, $params)

Inherited, see "Writing" in IOMux::Handler::Write

$obj->say(STRING|SCALAR|LIST|ARRAY)

Inherited, see "Writing" in IOMux::Handler::Write

$obj->write( SCALAR, [$more] )

Inherited, see "Writing" in IOMux::Handler::Write

Multiplexer

Extends "Multiplexer" in IOMux::Handler::Write.

Extends "Multiplexer" in IOMux::Handler::Read.

Connection

Extends "Connection" in IOMux::Handler::Write.

Extends "Connection" in IOMux::Handler::Read.

$obj->muxInit( $mux, [$handler] )

Inherited, see "Connection" in IOMux::Handler

$obj->muxInit( $mux, [$handler] )

Inherited, see "Connection" in IOMux::Handler

$obj->muxRemove()

Inherited, see "Connection" in IOMux::Handler

$obj->muxRemove()

Inherited, see "Connection" in IOMux::Handler

$obj->muxTimeout()

Inherited, see "Connection" in IOMux::Handler

$obj->muxTimeout()

Inherited, see "Connection" in IOMux::Handler

Reading

Extends "Reading" in IOMux::Handler::Write.

Extends "Reading" in IOMux::Handler::Read.

$obj->muxEOF()

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 close() callback will be called.

sub muxEOF
{   my ($self, $ref_input) = @_;
    print $fh "Well, goodbye then!\n";
    $self->shutdown(1);
}
$obj->muxExceptFlagged($fileno)

Inherited, see "Reading" in IOMux::Handler

$obj->muxExceptFlagged($fileno)

Inherited, see "Reading" in IOMux::Handler

$obj->muxInput($buffer)

Inherited, see "Reading" in IOMux::Handler::Read

$obj->muxReadFlagged($fileno)

Inherited, see "Reading" in IOMux::Handler

$obj->muxReadFlagged($fileno)

Inherited, see "Reading" in IOMux::Handler

Writing

Extends "Writing" in IOMux::Handler::Write.

Extends "Writing" in IOMux::Handler::Read.

$obj->muxOutbufferEmpty()

Inherited, see "Writing" in IOMux::Handler::Write

$obj->muxOutputWaiting()

Inherited, see "Writing" in IOMux::Handler::Write

$obj->muxWriteFlagged($fileno)

Inherited, see "Writing" in IOMux::Handler

$obj->muxWriteFlagged($fileno)

Inherited, see "Writing" in IOMux::Handler

Service

Extends "Service" in IOMux::Handler::Write.

Extends "Service" in IOMux::Handler::Read.

Helpers

Extends "Helpers" in IOMux::Handler::Write.

Extends "Helpers" in IOMux::Handler::Read.

$obj->extractSocket(HASH)
IOMux::Net::TCP->extractSocket(HASH)

Inherited, see "Helpers" in IOMux::Handler

$obj->extractSocket(HASH)
IOMux::Net::TCP->extractSocket(HASH)

Inherited, see "Helpers" in IOMux::Handler

$obj->fdset($state, $read, $write, $error)

Inherited, see "Helpers" in IOMux::Handler

$obj->fdset($state, $read, $write, $error)

Inherited, see "Helpers" in IOMux::Handler

$obj->show()

Inherited, see "Helpers" in IOMux::Handler

$obj->show()

Inherited, see "Helpers" in IOMux::Handler

SEE ALSO

This module is part of IOMux distribution version 1.01, built on January 15, 2020. Website: http://perl.overmeer.net/CPAN

LICENSE

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/