How do I know I have the full packet from a UDP message?
This is my first time working with a network!!!! I'm super excited and thank you for taking time to help me out. I thought you could use the recv function to look at parts of a udp message. I have someone sending me a message that could be up to 50000 bytes and in the header of that message he tells me how big the packet is. So I thought I could use recv to receive only the header first, then I could see how big the packet is and I would know when I have to full packet, but this method gave me 10040 socket error messages. So I'm just going to use a buffer that's 50000 bytes and receive the whole packet at once. My question is how will I know I have the full packet?
Re: How do I know I have the full packet from a UDP message?
Re: How do I know I have the full packet from a UDP message?
I guess you will need to first read up on what exactly the differences are between UDP and TCP.
Essentially, you cannot do what you were trying here. A UDP Datagram is either received in it's entirety or it isn't received at all. so you can't read only the header to then read the rest.
Also with UDP, you may not receive the packet at all, or you may receive duplicates. You will probably need some form of flow control.
Or use TCP as VictorN suggests which will do a lot of the nitty gritty for you in that respect, but then you loose the 'disconnected' flexibility UDP offers (as well as broadcast features).