in reply to Excuse me, is that port taken?
Two ways spring to mind. First, connect to the port yourself to see if anything is listening (untested):
And if you get a "connection refused" there's probably no listener.use IO::Socket::INET; $sock=IO::Socket::INET->new(PeerAddr => 'machinename', PeerPort => $portnumber, Proto => 'tcp');
Another way is to bind the port yourself. If it's a low-numbered port, you'll have to be root.
If you don't get a "port already bound" error, then it's not bound.use IO::Socket::INET; $sock=IO::Socket::INET->new(Listen => 1, LocalAddr => $interfaceaddres, LocalPort => $portnumber, ReuseAddr => 1, Proto => 'tcp');
If either of these fail, $sock will be undef and $! will have your error message.
|
---|
In Section
Seekers of Perl Wisdom