networking - buffer sizes

^
why is it that people make their buffers 256. 512. 1024 bytes long when sending and receiving messages?

why not something like 649 or 34 bytes?
It's generally because they're allocating a buffer for the maximum size of the message which is usually in increments of 2^x. Sometimes there are alignment issues and it can affect performance ( https://en.wikipedia.org/wiki/Data_structure_alignment ). In most cases, however, it doesn't and there's nothing wrong with allocating a buffer of size 649, assuming you know that's the size of the message you're receiving.
Topic archived. No new replies allowed.