Boost logo

Boost Users :

Subject: Re: [Boost-users] [asio] What happens when socket receive buffer overflows?
From: Jonathan Franklin (franklin.jonathan_at_[hidden])
Date: 2010-04-09 16:52:16


2010/4/7 Matheus Araújo Aguiar <matheus.pit_at_[hidden]>:
> 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.

It sounds like you have made the problem go away.

FWIW, on the send side of a TCP connection, you may do 4 individual
writes of 64 bytes each, but on the receive side you may only see 256
bytes of data available on the socket. TCP is a stream protocol, so
at the application level, there is no inherent concept of packets or
messages. TCP *uses* segments, which are packets on "the wire", but
gives you a stream at the application level when you read data from
the socket. So there is no correlation between the number of writes
on the send side, and the number of reads on the receive side. It
only guarantees that you will receive the bytes in the same order they
were sent... If you receive them at all. ;-)

You must design you socket reader with this in mind. Good luck! :-)

Jon


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