TCP:
http://www.cnblogs.com/likeyou1/p/8435120.html
UDP:
http://www.cnblogs.com/likeyou1/p/8435195.html