|
Boost : |
Subject: Re: [boost] Is the async_read more reliable than async_read_some?
From: hh h (jupiter.hce_at_[hidden])
Date: 2018-12-08 23:51:46
"If it uses some kind of delimiter, then async_read_until will work"
What kind of delimiter can I use to make async_read_until will work?
The server to call async_read_some will be connected by thousands
devices, can the async_read_some cope with thousands different
messages without causing problems?
I've just tried to run async_write using boost streambuf to pack
packet header and msgpack data together in one message data, but the
async_read in server site could only work a couple of minutes than it
crashed even I fixed all sizes in header file. It seems I can only use
the async_read_some for a stable server implementation.
On 12/8/18, Steven Watanabe via Boost <boost_at_[hidden]> wrote:
> AMDG
>
> On 12/07/2018 05:05 PM, hh h wrote:
>>> aynyc_read is essentially implemented by calling
>>> async_read_some repeatedly, until it fills
>>> the requested size.
>>
>> That is exactly the question I am going to ask, if you don't know the
>> package size to read, you have to call sync_read_some with
>> max_buffer_size, how does the sync_read_some function know the end of
>> the message? Obviously, that the end of the message length is smaller
>> than the max_buffer_size. Is some timeout defined in sync_read_some to
>> identify the end of the message?
>>
>
> The way to identify the end of the message
> depends on how the end of the message is
> represented. If it uses some kind of
> delimiter, then async_read_until will
> work. If you signal the end of the message
> by closing the connection, then you can
> just read until EOF (which is indicated
> by the error_code).
>
> In Christ,
> Steven Watanabe
>
> _______________________________________________
> Unsubscribe & other changes:
> http://lists.boost.org/mailman/listinfo.cgi/boost
>
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk