INTERNAL: Not to use already used port.
@@ -1047,13 +1047,17 @@ sub free_port {
my $type = shift || "tcp";
my $sock;
my $port;
+ my $netstat;
while (!$sock) {
$port = int(rand(20000)) + 30000;
+ $netstat = `netstat -tnau | grep $port`;
+ if ($netstat eq "") {
$sock = IO::Socket::INET->new(LocalAddr => '127.0.0.1',
LocalPort => $port,
Proto => $type,
ReuseAddr => 1);
}
+ }
return $port;
}
