Search code examples
cwinsocksenddata-transferrecv

Do send/recv transfer data in identical chunks?


From my client:

send(socket, "this is a buffer", ...);
send(socket, "second buffer", ...);

From my server, is recv guaranteed to end one chunk with the r from "this is a buffer" and begin another chunk with the s from "second buffer'?


Solution

  • No, not at all. You have no control over what happens when you receive the data due to all of the processing of the network. You can't make any assumption about how much you will get in any recv call (except for that it will be <= the amount sent). You could get as little as one byte.