I have the following code (part of a larger script)
my $lsn = IO::Socket::INET->new(Listen => 1, LocalPort => 0); # just use any available port.
$port = $lsn->sockport();
I'm getting the error Can't call method "sockport" on an undefined value
.
The documentation for IO::Socket::INET
doesn't say much on this issue: https://perldoc.perl.org/IO/Socket/INET.html (is there a better place to look? Not too familiar with this module).
Strange thing is that I recently changed this, before it passed in a non-zero, randomly-generated port number, and that would sometimes break, when the port was in use.
I tested passing in 0
on my local windows machine(again, the documentation doesn't seem to mention how to get it to choose the port to bind), and that seemed to make it 'choose any available port', which is what I wanted, but maybe it behaves differently on Solaris (which is where this problem occurred)?