Boost logo

Boost Users :

Subject: [Boost-users] [asio] asynchronous reading/writing to the tcp stream
From: Ovanes Markarian (om_boost_at_[hidden])
Date: 2012-07-11 10:44:24


Hello *,

I go through the ASIO docs, but somehow do not get if I can implement
the following scenario:

In one thread I would like to send lot's of commands to the server via
a tcp connection.
In the other thread I would like to start reading the commands being
already handled and returned by the server.

The commands are parsed by Spirit.QI. My idea was to use a
tcp::iostream asynchronously so that I just pass the begin iterator to
the output stream to QI and receive parsed data. If there is no output
from the server the iterator should block and wait for it. This is a
producer-consumer problem, but I would like to solve it with
tcp::iostream and without explicit synchronization on my side. Is it
possible? If yes, than how?

I understand that I can introduce some storage, read bytes to it and
notify my hand-crafter iterator, that there is some data that can be
read again, but is there a better approach?

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