Recently, Jon Cole from the System.Net QA team posted a great article in response to questions we’ve received on our .Net Networking Forum (http://forums.microsoft.com/MSDN/ShowForum.aspx?ForumID=40&SiteID=1). His post can be found here: http://blogs.msdn.com/joncole/archive/2006/03/20/555721.aspx
Excerpt from the article:
A common misunderstanding for developers new to network programming over TCP sockets is how messages are sent and received. I frequently hear the statement that “my data is not arriving on the other side of the socket in the same format that I sent it.” The most common cause of this is because the TCP protocol does not guarantee that it will keep message boundaries. In other words, you could send “Hello World” in a single call to Send(), but the other side of the socket stream may have to do multiple Receive() calls on the socket to get all of the data (the first Receive might return “he” and the second “llo world”). ……..
— Mike Flasko