In python docs https://docs.python.org/3/library/socket.html it says about socket.recv(bufsize[, flags])
the following:
Note
For best match with hardware and network realities, the value of bufsize should be a relatively small power of 2, for example, 4096.
Why exactly so? Wouldn't it be better to set it arbitrarily large (like 1000000000) so that we receive the most of what we can receive? I assume that the message would still be probably cut off after some KBs. But if we set buff_size
to 4096, we risk the situation when we get e.g. 8192 Bytes, and have to perform one more iteration of reading from the stream, while we could get everything at once with buff_size=100000000