A couple of questions about TCP.
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)
First things first. When sending the packet, what are the pros/cons of the two following options;
NetworkStream ns = client.GetStream();
ns.Write(BitConverter.GetBytes(100));
ns.Write(BitConverter.GetBytes("Test"));
or
NetworkStream ns = client.GetStream();
byte[] payload = BitConverter.GetBytes(100).Concat(BitConverter.GetBytes("Test"));
ns.Write(payload); //, 0, payload.Length);
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.