谈论套接字时的同步和异步术语

Synchronous and asynchronous terminology when talking about sockets

我不完全理解他们说的是什么意思:“异步读写操作”或“同步读写操作。

我将举例说明我对术语的理解,如有错误请更正:

我认为它与执行的调用线程有关。

同步意味着执行的调用线程与操作'in sync'。因此,当调用 returns 时,调用线程具有可使用的操作数据。

异步意味着执行的调用线程与操作同步。因此,当调用线程 returns 来自操作时,它可能有来自操作的数据,也可能没有;它需要处理这两种情况。

没有。非阻塞套接字上的操作是同步的。

在Windows中,"overlapped I/O"是"asynchronous I/O"的同义词。

Read and write on a socket in a blocking mode is considered synchronous.

是的。

Read and write on a socket in a non-blocking mode is considered asynchronous.

没有。它是同步的。当前线程内联操作完成或失败。

Read and write on a socket using Overlapped I/O is considered asynchronous.

正确。函数调用post要完成的操作,独立于当前线程进行,需要后面的操作判断其成功或失败,或者有完成回调。