C# How to handle TCP packets/segments <p>A couple of questions about TCP. </p> <p>I know that the packet will be "split" or fragmented if it hits a network device with lower MTU etc. But the problems I have is understanding how I "rebuild" my payload in the application. (I've been trying for 2-3 hours now, but can't seem to get it right)</p> <p>First things first. When sending the packet, what are the pros/cons of the two following options;</p> <pre><code>NetworkStream ns = client.GetStream(); ns.Write(BitConverter.GetBytes(100)); ns.Write(BitConverter.GetBytes("Test")); </code></pre> <p>or</p> <pre><code>NetworkStream ns = client.GetStream(); byte[] payload = BitConverter.GetBytes(100).Concat(BitConverter.GetBytes("Test")); ns.Write(payload); //, 0, payload.Length); </code></pre> <p>And how do I rebuild the payload at the recv. part if it has been split? I would love a spoon-feeding on this one as I seem to miss some very important, but not so obvious, part in my current application.</p>