My favorite net sniffer program is
http://www.wireshark.org/[
^] that uses the libpcap library to do the stuff. This is perfect for tcp and sniffing but for https you might need some more work. In some cases you can use the "man in the middle" approach where the program connects to your "man in the middle" program and your program connects to the original destination of the https connection. This way your program just acts as a proxy between the two endpoints and can see the unencrypted data channel traffic. This doesn't work all the time, but others might be able to give you better ideas because I havent done such tricks often.