Hello List,

I have a network application written with asio that uses TCP. The message exchange between client and server is done using a protocol that puts a prefix on each message indicating the number its bytes number. This way, at one side a prefix is read, and the number of bytes indicated in the prefix is read as a message, then it reads another prefix and so on.

While testing the application I was having some errors related to reading a prefix that would indicate a strange number of bytes incoming, a number that was far greater than the max size possible of message in my protocol. After assuring that the bytes on the stream were not being merged, i started suspecting about socket buffer size. So i reduced the socket buffer size to 1K, and the application crashed with a lot less network load than before.

At the moment, i am almost sure that the problem is the socket receive buffer which overflows and the bytes are discarded, creating a "gap" in the byte stream which causes an inconsistent state on the application. Does that make sense? What should happen when the socket receive buffer overflows? It silently discards the bytes or what?

Thanx for your attention,
--
Matheus Araújo Aguiar
Computer Scientist
matheus.pit@gmail.com