Network analyser - http://www.ethereal.com/
Use this to
1. Watch what existing browser / email / ftp / chat client does already
2. Watch what your program is doing different, if you're writing a browser / email / etc
In a similar (or perhaps even the same vein), there's Wireshark, which is either the new name for ethereal, or a fork (I don't know which).