Proactor and async write

Deadly 提交于 2019-12-10 18:59:06

问题


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.

  1. Why we need is async write? Is it useful for TCP/UDP connection too (can write to TCP/UDP socket take time)?
  2. Can I mix async read with sync write?

回答1:


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.



来源:https://stackoverflow.com/questions/5554990/proactor-and-async-write

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!