|
What most systems use is a large buffer which you use to accept the incoming data and then transfer it over to a new buffer for processing based on the actual size of packet received.
So your socket system might have a main buffer of... say 10,000 or 50,000 bytes (just an example) which you use for receiving data. Once that is done you could create a new byte array using the information on what has ACTUALLY been received, process that packet and then clear the original buffer.
I'm positive there are better methods out there but that's what most I've seen use.
|