eltonsky
eltonsky

Reputation: 367

c++ boost:asio convert socket to stream?

I am using boost::asio in both async and sync way. One thread in my application async_accept a socket, and the other thread read/write from that socket synchronously.

AFAIK boost::asio::ip::tcp::iostream object can be created by connecting to an endpoint directly. I am looking for a way to get a stream object from a socket obj, so I can make my communication lib generic. Is there a way to get that object from an socket obj?

Upvotes: 4

Views: 1775

Answers (1)

Öö Tiib
Öö Tiib

Reputation: 11021

Avoid internally mixing sync with async. Externally emulate one of those using other. Since asio is async use it async and emulate sync by waiting async operation to complete.

Upvotes: 1

Related Questions