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

Test::TCP::Multi - Test Using Multiple Servers/Clients

SYNOPSIS

    use Test::MultiTCP;

    test_multi_tcp(
        server1 => sub {
            my ($port, $data_hash) = @_;
        },
        server2 => sub { ... },
        server3 => sub { ... },
        client1 => sub {
            my ($data_hash) = @_;
        },
        client2 => sub { ... },
        client3 => sub { ... }
    );

WARNING

This code is mostly a copy of Test::TCP, but the portions that I wrote are eh... a HACK. Don't use unless you can debug things yourself!

DESCRIPTION

Test::TCP allows you to run client/server tests. With Test::TCP::Multi, you can have multiple servers and clients.

SERVERS

Any key that starts with the string "server" (case-insensitive) is considered to be a server. Test::TCP::Multi will attempt to find an open port for any of these entries.

Server callbacks should expect two arguments, the port number you should use, and a hashref containing pids of each entry, and a port number (if the entry is a server)

UNLIKE Test::TCP, YOU HAVE TO KILL THE SERVERS YOURSELF! This is because there's no way for Test::TCP::Multi to know if you're really done with the servers or not. Simply do something like

    kill_proc($data_hash->{ your_server_name }->{pid});

CLIENTS

Any key that starts with the string "client" (case-insensitive) is considered to be a client.

Server callbacks should expect two arguments, the port number you should use, and a hashref containing pids of each entry, and a port number (if the entry is a server)

AUTHOR

The important bits by Tokuhiro Matsuno (Test::TCP)

The hacked up stuff by Daisuke Maki <daisuke@endeworks.jp>

LICENSE

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