17 Oct
2017
17 Oct
'17
11:32 a.m.
I have created an Asynchronous TCP server and client and it works fine. Since it is asynchronous, it uses API’s like async_read, async_write etc.. Is it possible that the same code be used to do “synchronous” communication which results in blocking any further task in the queue unless the current i/o task is complete ?
You can do that with synchronization: std::condition_variable cond; std::mutex mutex; auto done=false; after you call asyn_write/read, you wait until done==true and in your call back function, you acquire the mutex, done == true, then notify_all(). F