Boost asio implements proactor design pattern baded on ACE proactor.
I understand why we need async read. Hovewer, I'm a confused with async write.
- Why we need is async write?
Is it useful for TCP/UDP connection too (can write to TCP/UDP socket take time)?
- Can I mix async read with sync write?
1) Why we need is async write? Is it useful for TCP/UDP connection too (can
write to TCP/UDP socket take time)?
Asynchronous write is needed for the very same reasons as asynchronous read. When using synchronous write operations, the calls block until all data has been transmitted. This is not desirable for a number of reasons. Primarily to achieve concurrency without use of explicit threads, this is the basis of the proactor design pattern.
2) Can I mix async read with sync write?
Yes, they can and should be mixed. It would be a very odd design to use asynchronous read operations, yet synchronous write operations.