1

I am coding network stuff via tcp/ip.

Specifically I have been using boost::asio.

Recently, to ease coding, I started using boost::asio::ip::tcp::iostream. It can be useful for fast developing! But I am not sure whether it uses async_read or async_write.

Does anybody know whether it does?

sehe
  • 374,641
  • 47
  • 450
  • 633
user9414424
  • 498
  • 3
  • 15

1 Answers1

0

No it cannot. That's most of what makes it so simple.

However, you can force a full-duplex experience using boost::asio::ip::tcp::iostream with some tweaks. You'll need to run the reading/writing tasks on separate threads to achieve the parallellism without having asynchrony.

An examples of this - what I consider to be a - hack, is here:

How to avoid data race with `asio::ip::tcp::iostream`?

That answer does also give the asynchronous approach, so that may help remove the intimidation factor because you can simply compare side-by-side both approaches.

sehe
  • 374,641
  • 47
  • 450
  • 633