
On Thursday, May 12, 2011 10:36 AM, Slav wrote:
Yeah - I was really mistaken. Thanks for correcting me.
I reimplemented the reading using message length prefix and now everything works fine.
Left just one question: socket has "receive_buffer_size" option which is by default equals 8192 - does it mean that message of length (if it will come at once) will be truncated? Or I still could read it with multiple "async_read" calles (collecting it into a buffer using data length prefix)?
TCP will not alter the byte stream, also meaning it will not drop bytes. If the receive buffer fills, then it will tell the other machine it is sending data too fast and needs to slow down. It will also have the other machine resend the data that couldn't fit in the receive buffer. Your programs (on both ends) will not need to address this issue; the operating system will handle it for you. That said, experimenting with the receive buffer size may improve performance, but will have no effect on correctness. Don't assume more is better. If you make the buffers too big, you'll just increase overhead and latency.