Marc Goldberg's Blog
OS X Pro Tip: lsof

If you’ve ever wondered what process has which file or TCP port open, try out the lsof command in your nearest terminal window.  For example, lsof -i4 will let you know which processes are using which ports.

man lsof for more happy goodness.