My long term understanding of sockets was that a call to recv() could not be relied upon to return the requested amount of data (be it blocking socket or not)
I was trying to prove this to a colleague by sending large (1mb) amounts of data in one call to send (from my home, to his home over a works VPN network - multiple routers wifi etc involved)
The sockets are blocking so I don't expect the send() to return anything but 1mb and do it in one go, but I did expect the recv() calls to return less than 1mb even though the socket is blocking.
The background for this test was to persuade him that we need a length and payload in the message protocol so you know where messages start/end, and you can't rely on one recv() call returning one message. Also to show him a simple recv() isn't even enough if we do have this protocol, we need to recv() in a loop, even for say the 4 byte message length field, incase recv() doesn't return the requested size.
Is my understanding of TCP comms wrong? Have I just been doing it overkill all these years? If not how can i force these recv() to come in fragmented?
recv()
call. Try with 10MB, or even 100MB. - President James K. Polk