Boost logo

Boost Users :

Subject: Re: [Boost-users] [asio] What happens when socket receive bufferoverflows?
From: Matheus Araújo Aguiar (matheus.pit_at_[hidden])
Date: 2010-04-09 14:46:18


Thanks for your reply Cliff,

On Fri, Apr 9, 2010 at 2:50 PM, Cliff Green <cliffg_at_[hidden]> wrote:

> Not sure if anyone replied yet or not ...
>
> >> ... protocol that puts a prefix on each message indicating the number
> its bytes number.
>
> Yes, a fairly common design (I've done a variation on it at least a dozen
> times).
>
> >> ... 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 ...
>
> Also pretty common problem. I'd bet a major body part there's a bug in the
> sending (or receiving) side of the app. Something has dropped some bytes
> somewhere, or lost track of where it is in the "message framing".
>
> >>... 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.
>
> As mentioned, you're probably on the mark as to why you're crashing. But
> not as to the underlying cause.
>
> You're focusing on an OS or TCP stack problem, rather than your code. The
> TCP protocol has "flow control" built in, and if the receiving side fills up
> or is congested, it will tell the sending side to quit sending. If packets
> get dropped while the flow control is "kicking in", the packets will
> (eventually) get re-transmitted. (On a side note, this type of congestion
> can be a system-level problem, with certain use cases.)
>
Probably you are right. Believing that the problem was with the buffer, i
modified the way i read from the socket, in order to make it faster, and the
problem is not occurring anymore.

>
> >> ... What should happen when the socket receive buffer overflows? It
> silently discards the bytes or what?
>
> TCP never "silently discards" bytes (UDP will, obviously). There's a bug in
> your code (including the way you're using Asio).
>
> Asio streambufs or iostreams can leave characters in the buffer, and your
> logic must account for these.
>
> If you're still having the problem, reduce your code to the smallest
> example that will reproduce the crash, and post it to the mailing list
> (there's also an Asio mailing list you can use).
>
> Cliff
>
>
> _______________________________________________
> Boost-users mailing list
> Boost-users_at_[hidden]
> http://lists.boost.org/mailman/listinfo.cgi/boost-users
>

-- 
Matheus Araújo Aguiar
Computer Scientist
matheus.pit_at_[hidden]


Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net