简体   繁体   中英

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?

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM