I'm using boost::asio library for creating full duplex server. I wondering whether this situation is possible to happen.
The question is whether I need separate buffer for every write operation or in point 3 the buffer is copied in some kind of internal buffer and I can safely to fill the new response in the same buffer?
boost::asio is able to do full-duplex operation, but you should manage buffers carefully.
The general rules is:
So you can do 1 write and 1 read operation simultaneously.
Situation you described should work in single-threaded environment since process cannot add to buffer and use it for write simultaneously. But, there is a trick however: after you append to write buffer you cannot know is current async_write done or not. Do you need to start new async_write or not? This moment needs to be carefully verified.
PS And no, asio never copies buffers internally.
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.