Simple .NET TCP Framing Example

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 (  His post can be found here:

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