So ive been reading a game development book lately on C#/XNA. As I learn more always think "how do people do this, and how do people do that". This is one of them moments. I am aware of very basic networking concepts/stratergies.
Im going to get straight to it: What happens when you send a tcp message (packet) larger than it should be. Does the Send() code throw an exception saying the packet is too big, if so what is the actual maximum packet size? Even though the defined maximum tcp/udp packet size is 64kb, ive heard from almost everywhere this is not a safe size as other technologies limit the size.
Say if the packet IS to big and a exception is thrown but there is still more data needs to be sent? Do you split up the transmission into certain x bytes per packet and then would you create a start/end ANSII (or unicode whatever) character at the begin/finish of a data transmission? The start character will be a ANSII in the start of the first packet and the end ANSII character will be in the last packet. Once the end ANSII character has been recieved the receiver then knows all data has been read and then processes the data? Is this a good stratergy?
While im asking this, do packets always get received in FULL (well definately for TCP) right? Not incremental (e.g. 10 bytes each milisecond for 100 miliseconds for the whole packet, im just using this as an example), if this is true im guessing there is no need to create this:
while(NetworkObject.IsDataAvailable)
{
read byte by byte here until all data is read?
}
but instead just this:
byte[] data_received = NetworkObject.Receive(); //Blocking call; this is assuming packets are received full and there is no need to read each byte.
Thanks,
Xanather
All answers/helpful replies are greatly appriciated.
Edited by Xanather, 28 May 2012 - 07:22 AM.






