Subject: | No way to automatically select a free listening port |
With IO::Socket you can pass a local port of "0" then system will then
pick the next free high port.
You can then use the following code to get the value that was assigned:
my $sockAddr = getsockname($socket);
my($port, undef) = sockaddr_in($sockAddr); #get the port number that
linux gave us
To fix you could to the following in the contructor:
my %params = (
'Proto' => 'udp',
'LocalPort' => $cfg{'LocalPort'} #use local port if given
);
Rather than:
my %params = (
'Proto' => 'udp',
'LocalPort' => $cfg{'LocalPort'} || TFTP_DEFAULT_PORT,
);
I'm not sure how portable this would be