刘刊 > DynGig-Multiplex-1.02 > DynGig::Multiplex::TCP

Download:
DynGig-Multiplex-1.02.tar.gz

Dependencies

Annotate this POD

CPAN RT

Open  1
View/Report Bugs
Source   Latest Release: DynGig-Multiplex-1.03

NAME ^

DynGig::Multiplex::TCP - Multiplexed TCP Client

SYNOPSIS ^

 use DynGig::Multiplex::TCP;

 ## imagine these servers are echo servers ..

 my @server = qw( host:port /unix/domain/socket ... );
 my %config = ( timeout => 30, buffer => 'bob loblaw' );
 my $client = DynGig::Multiplex::TCP->new( map { $_ => \%config } @server );

 my %option =
 (
     timeout => 300,     ## global timeout in seconds
     max_buf => 1024,    ## max number of bytes in each read buffer
     multiplex => 100,   ## max number of threads
     index => 'forward'  ## index results/errors by server
     verbose => *STDERR  ## report progress to STDERR
 );

 if ( $client->run( %option ) )
 {
     my $result = $client->result() || {};
     my $error = $client->error() || {};
 }
 else
 {
     print $client->error();
 }

DESCRIPTION ^

run

Launches client with the following parameter. Returns 1 if successful. Returns 0 otherwise.

 index     : index results/errors by server if set to 'forward'
 timeout   : global timeout in seconds
 max_buf   : max number of bytes in each read buffer
 multiplex : max number of threads
 verbose   : report progress to a file handle opened for write.

result()

Returns undef if no result. Returns a HASH reference indexed either by server or by result (see the index parameter of run().)

error()

Returns undef if no error. Returns a string if a global error occurred, else if errors occurred with individual client/server connections, returns a HASH reference indexed either by server or by result. (see the index parameter of run().)

SEE ALSO ^

Socket and IO::Poll

NOTE ^

See DynGig::Multiplex

syntax highlighting: