X-Git-Url: https://git.exim.org/users/heiko/exim.git/blobdiff_plain/b16852e23e1c477797bd7ce578a0f96bf341341c..b369d47038a075706f6dfe57ab2e1ebeea0e5bdf:/test/lib/Exim/Runtest.pm?ds=sidebyside diff --git a/test/lib/Exim/Runtest.pm b/test/lib/Exim/Runtest.pm index 2ac9a61ee..1df2ea1a9 100644 --- a/test/lib/Exim/Runtest.pm +++ b/test/lib/Exim/Runtest.pm @@ -1,6 +1,7 @@ package Exim::Runtest; use strict; use warnings; +use IO::Socket::INET; use Carp; use List::Util qw'shuffle'; @@ -22,7 +23,19 @@ sub mailgroup { push @groups, $_ while defined($_ = getgrent); endgrent; return (shuffle @groups)[0]; -}; - +} + +sub dynamic_socket { + my $socket; + for (my $port = 1024; $port < 65000; $port++) { + $socket = IO::Socket::INET->new( + LocalHost => '127.0.0.1', + LocalPort => $port, + Listen => 10, + ReuseAddr => 1, + ) and return $socket; + } + croak 'Can not allocate a free port.'; +} 1;