Sometimes its useful to know who’s LISTENing on a socket. On GNU/Linux and similar systems, the command netstat -lp provides a listing of all sockets on which processes on your system are listening for connections, along with the process IDs/names of these processes. Unfortunately, it seems the MacOS (Leopard) version of netstat does not support the -p option. Fortunatly, Leopard does come with that Swiss army knife of process and file info, lsof, which among other things can display socket info.
For instance, to find the process that was listening on port 3000 on my system, I used: lsof -i 4:3000. The -i arg is used to specify the type of socket/connection we are looking for, the 4 denotes IPv4 and the 3000 is of course the port we are interested in.