The London Perl and Raku Workshop takes place on 26th Oct 2024. If your company depends on Perl, please consider sponsoring and/or attending.

NAME

Multiplex::TCP - Multiplexed TCP Client

VERSION

This documentation describes version 0.01

SYNOPSIS

 use 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 = Multiplex::TCP->new( map { $_ => \%config } @server );

 my %option =
 (
     timeout => 300,    ## global timeout in seconds
     max_buf => 1024,   ## max number of bytes in each result
     multiplex => 100,  ## max number of threads
     index => 'forward' ## index results/errors by server
 );

 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 result
 multiplex : max number of threads

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

AUTHOR

Kan Liu

COPYRIGHT and LICENSE

Copyright (c) 2010. Kan Liu

This program is free software; you may redistribute it and/or modify it under the same terms as Perl itself.