Mark Overmeer > IOMux-0.13 > IOMux::Net::TCP

Download:
IOMux-0.13.tar.gz

Dependencies

Annotate this POD

View/Report Bugs
Module Version: 0.13   Source  

NAME ^

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

INHERITANCE ^

 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

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'
    , 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
    );
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->mux_init( MUX, [HANDLER] )

Inherited, see "Connection" in IOMux::Handler

$obj->mux_init( MUX, [HANDLER] )

Inherited, see "Connection" in IOMux::Handler

$obj->mux_remove()

Inherited, see "Connection" in IOMux::Handler

$obj->mux_remove()

Inherited, see "Connection" in IOMux::Handler

$obj->mux_timeout()

Inherited, see "Connection" in IOMux::Handler

$obj->mux_timeout()

Inherited, see "Connection" in IOMux::Handler

Reading

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

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

$obj->mux_eof()

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);
  }
$obj->mux_except_flagged(FILENO)

Inherited, see "Reading" in IOMux::Handler

$obj->mux_except_flagged(FILENO)

Inherited, see "Reading" in IOMux::Handler

$obj->mux_input(BUFFER)

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

$obj->mux_read_flagged(FILENO)

Inherited, see "Reading" in IOMux::Handler

$obj->mux_read_flagged(FILENO)

Inherited, see "Reading" in IOMux::Handler

Writing

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

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

$obj->mux_outbuffer_empty()

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

$obj->mux_output_waiting()

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

$obj->mux_write_flagged(FILENO)

Inherited, see "Writing" in IOMux::Handler

$obj->mux_write_flagged(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 0.13, built on July 21, 2015. 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

LICENSE ^

Copyrights 2011-2015 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

syntax highlighting: