in reply to Re: Could not create socket: Bad file number
in thread Could not create socket: Bad file number

AFAIK, IO::Socket::INET->new() does not set $!

It's poorly documented, but IO::Socket and its INET subclass put their informative errors into $@. So, the OP wants something like:

my $s = IO::Socket::INET->new(...) or die "new sock: $@\n";

-pilcrow