boards > tech > Using multiple ports/sockets with Net::Server

ownericonuserlame
Joined: 2004-03-17
Posts: 663
2008.12.04 - 19:10:25 PDT
The documentation for Net::Server mentions the ability to bind to multiple ports, but doesn't describe how to do it. I didn't find much else on the interwebs describing it either.

To bind to multiple ports/sockets, just pass an array reference as the port.

For example:
my $server = Net::Server::PreFork->new();
$server->run(port => [ "/path/to/socket|unix", "127.0.0.1:10001" ])

or
my @ports = ("/path/to/socket|unix", "127.0.0.1:10001");
my $server = Net::Server::PreFork->new();
$server->run(port => \@ports);


Simple enough.
hit counter