Boost logo

Boost Users :

Subject: Re: [Boost-users] [asio] asynchronous reading/writing to the tcp stream
From: Ovanes Markarian (om_boost_at_[hidden])
Date: 2012-07-11 12:42:51


On Wed, Jul 11, 2012 at 6:27 PM, Nat Linden <nat_at_[hidden]> wrote:
> On Wed, Jul 11, 2012 at 12:05 PM, Ovanes Markarian
> <om_boost_at_[hidden]> wrote:
>
>> On Wed, Jul 11, 2012 at 5:10 PM, Nat Linden <nat_at_[hidden]> wrote:
>
>>> When you want code that appears to block, but is actually driven by
>>> asynchronous I/O, that's a use case for Boost.Coroutine.
>>> Interestingly, the new Coroutine is supposed to be reviewed very soon:
>>> http://olk.bplaced.net/boost-coroutine.zip
>
>> Nat thanks for the quick reply... But what happens with the
>> tcp::iostream if another thread starts to read from it after a
>> connection was open, but no response is there? Would not it block? Is
>> it even safe to write requests to the tcp::iostream from one thread
>> and read it from the other? As I stated before, I would like to solve
>> the issue with ASIO only. I might be able to review coroutine lib, but
>> I don't think this an option for us in this project.
>
> coroutine != thread. :-)
>
> A coroutine is user-space context switching, and it happens at
> well-defined times. It's just a way of organizing code that must
> otherwise be structured to receive intermittent calls -- as with an
> ASIO completion handler.

Nat,

I know what coroutines, fibers or user space threads are... But using
them I still need to do some additional impl, which I don't want. I
first want to know if I can read/write to tcp::iostream from two
different threads and if yes, than how should I do it best.

Thanks,
Ovanes


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