|
Boost Users : |
Subject: Re: [Boost-users] Boost.Asio -- combining sync read with async read
From: Igor R (boost.lists_at_[hidden])
Date: 2009-10-14 10:02:45
>
> async_read_until() and have it call my fill handler when it receives
> something.
>
> Then the function that submits orders would call
>
> write()
>
> and then block waiting for the ack message using
>
> read_until()
>
> However, when I implement that, the client never seems to notice that a
> fill message is sent. It receives the acks just fine, and it successfully
> reads the datafeed coming in from the other tcp connection. I thought maybe
> the read_until() would cancel the async_read_until() so after I received the
> ack message I called async_read_until() again, but that didn't work
> either...
>
> (The server works as it should, I tested it with telnet.)
>
> Is it possible to mix sync/async reads in this way? Can anyone tell if I am
> doing something wrong? Do I need to do something else to make this work?
>
It's ok to use both sync. and async. calls, but you should not call
boost::asio::async_read_until() and/or boost::asio::async_read() until
previous read is complete (for the same socket/buffer). Besides, pay
attention that reading "until" might read more data than you expect.
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