Boost logo

Boost Users :

Subject: Re: [Boost-users] Using boost::asio::async_write to stream out data
From: Matheus Araújo Aguiar (matheus.pit_at_[hidden])
Date: 2009-07-17 14:50:26


>
>
> 3. I understand I can't call async_write again before the first one has
>> been completed (since I don't want my 8kb chunks interleaved), so should
>> I maintain a queue of buffers waiting to go out?
>>
>>
>
> Correct. You need to check your queue in the completion routine and kick
> off
> another async_write if required. I typically use a std::deque to handle
> this for
> me. Sometimes just a std::deque< std::string > depending on the
> application.
>

>
>
> Then in my handle_write method should I check the queue, if at least one
>> buffer is in the queue then I should start a new async_write?
>>
>>
>
> Exactly.
>

I disagree. I don't have much technical knowledge about how it is done on
the O.S layer, but for what i've experienced, you can call several
async_write, one after another, without having to wait for the completion of
any of the operations. If you call async_write from diferent threads, then
data could be interleaved. And with TCP you may get data concatenated, but
it has to do with the protocol.

Maybe i'm wrong, but for now that's what i think. A third (and fourth, fifth
and so on) opinion would be nice.

-- 
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