Boost logo

Boost Users :

Subject: Re: [Boost-users] [asio] socket::read_some() splits data into two parts.
From: Eric J. Holtman (eric_at_[hidden])
Date: 2011-05-11 11:51:53


On 5/11/2011 10:11 AM, Slav wrote:
>
>
> TCP contains info about message length - it is duplication to prefix all
> messages with it's length.
>

No, it really doesn't. All you get is a stream of bytes,
reliably delivered, in sequence.

So if you write 3,732 bytes onto a socket, there is *NO WAY*
for the reader to tell that you did that. The reader might
get 1 read of 3732 bytes, or 3732 reads of 1 byte, or anything
in between.

The reader could even read *more* than 3732 bytes in one read,
if you wrote more than once.

If you think you're going to get repeatable, identical matching
pairs of reads and writes out of just a TCP socket (that is,
without imposing your own protocol on top of TCP), you are
in for endless hours/days/months of frustration.


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