Perl: the Markov chain saw | |
PerlMonks |
Re: What's the best way to find an unused TCP port on the local systemby ikegami (Patriarch) |
on Oct 20, 2006 at 17:39 UTC ( [id://579654]=note: print w/replies, xml ) | Need Help?? |
If using socket Bind to port zero. The system will pick an unused port. You can find out the number of the port to which the socket was bound as follows:
If using IO::Socket/IO::Socket::INET Don't specify a LocalPort or use LocalPort => 0. The system will pick an unused port. You can find out the number of the port to which the socket was bound as follows:
Update: Added IO::Socket method.
In Section
Seekers of Perl Wisdom
|
|