Skip to main content
1 of 2
Elva
  • 3.2k
  • 15
  • 13

The "problem", in this case, is that for any "What is better?" question, the answer will inevitably be "Well, that depends".

Phillips answer looks at it from a pure network protocol standpoint, pointing out that each packet will have overhead that could be avoided and things like packetloss and the routers in between the host and the client.

My answer doesn't delve into that (though that is part of the reasoning behind it, Phillip's answer is better) but notes that in standard TCP this doesn't really come up either way due to Nagle's algorithm.

Panda Pajama's answer points out that TCP is a stream protocol, you're not sending packets, your adding data to a stream that may be send in a single packet, it could also be split up at arbitrary point (even inside of one of your calls to send!).

All of these answers are different points of view on the same question, they don't contradict each other as much as complement each other. The reason you are getting multiple answers is that there are multiple answers, in some cases, small packets are better, in others larger. You're gonna have to figure out what is best for your application.

How you figure that out is typically by implementing the easiest and seeing if there are problems with using it in your application, if there are, you can see if it's worth trying out an alternative to make it work better.

Elva
  • 3.2k
  • 15
  • 13