socketsnetwork-programming

Multiple send() method calls and 1 receive method. Is this normal?


If on the client side I connect to a server and invoke the Send() method on the socket sending short data many times, is it normal that the server sometimes receives only one 'packet' which contains all the accumulated data which is the sum of many sending methods?


Solution

  • Yes. TCP is a stream, there's no concept of an individual "packet" - you should expect to receive everything one byte at a time, everything merged together or anything in between.

    The only guarantees are that no data will be lost, and that it'll arrive in the same order you sent it.