Test::TCP::Multi - Test Using Multiple Servers/Clients
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 { ... } );
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!
Test::TCP allows you to run client/server tests. With Test::TCP::Multi, you can have multiple servers and clients.
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});
Any key that starts with the string "client" (case-insensitive) is considered to be a client.
The important bits by Tokuhiro Matsuno (Test::TCP)
The hacked up stuff by Daisuke Maki <daisuke@endeworks.jp>
<daisuke@endeworks.jp>
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
To install Test::TCP::Multi, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Test::TCP::Multi
CPAN shell
perl -MCPAN -e shell install Test::TCP::Multi
For more information on module installation, please visit the detailed CPAN module installation guide.