Is there an optimal byte size for sending data over a network?

后端 未结 9 2125
既然无缘
既然无缘 2021-02-19 15:25

I assume 100 bytes is too small and can slow down larger file transfers with all of the writes, but something like 1MB seems like it may be too much. Does anyone have any sugge

9条回答
  •  时光说笑
    2021-02-19 16:29

    If you can, just let the IP stack handle it; most OSes have a lot of optimization already built in. Vista, for example, will dynamically alter various parameters to maximize throughput; second-guessing the algorithm is unlikely to be beneficial.

    This is especially true in higher-order languages, far from the actual wire, like C#; there are enough layers between you and actual TCP/IP packets that I would expect your code to have relatively little impact on throughput.

    At worst, test various message sizes in various situations for yourself; few solutions are one-size-fits-all.

提交回复
热议问题