The netstat command will show you the status of your network connections
netstat -natWill print out a list of all open TCP connections with ports (on Linux, check your local manpage if you're running a different *NIX, netstat tends to have subtly different syntax on the different variants). Since you're only communicating on the local host you'll likely only be interested in communications on 127.0.0.1
netstat -nltwill print out a list of sockets your machine is listening on (and which are therefore blocked). For Linux you can also add "-p" to give you the processes listening on these sockets (if you're root).
BTW, if you're expecting to want to reuse the same port for a different process a lot, you should set SO_REUSEADDR when opening the socket for listening.
Update: Check out Net::Netstat::Wrapper for a Perl interface to netstat
In reply to Re: Checking if a port is allready used
by tirwhan
in thread Checking if a port is allready used
by Outaspace
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |