Doing a Socket.Receive(byte[]) will get the bytes in from the buffer, but if the expected data is fairly large, all of the bytes might not yet be in the buffer, which would give me an only partially filled byte array. Will this code ensure that I read in all that I want?
sock.Receive(message_byte, message_byte.Length, SocketFlags.None);
where message_byte has already been declared as the exact size of the data I’m expecting. Am I going about this in the right way? Nothing this handles would be larger than ~10 megs, so it’s unlikely I would have an OutOfMemoryException when declaring the byte array.
No,
Receivereturns number of received bytes. You should properly handle this.