最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

c++ - Understanding Windows IOCP and Overlapped IO: Order of Completion and Message Sequencing - Stack Overflow

programmeradmin0浏览0评论

I have two questions regarding Windows IOCP (I/O Completion Ports) and Overlapped I/O:

1. Order of Asynchronous I/O Operations: In Jeffrey Richter's book Windows Via C/C++, the following statement is made:

"You should be aware of a couple of issues when performing asynchronous I/O. First, the device driver doesn't have to process queued I/O requests in a first-in first-out (FIFO) fashion."

This implies that when calling Overlapped I/O functions, the operations might not be processed in the order they were initiated. Here's an example:

// part of iocp tcp server
WSASend( ... ); // 1
WSASend( ... ); // 2
WSASend( ... ); // 3

Is Windows allowed to process the WSASend calls out of the order in which they were called? However, since TCP inherently guarantees message order, how is message sequencing ensured when using Overlapped I/O functions?

2. Completion Notification Order in IOCP: It's mentioned that in IOCP model servers, completion notifications might not arrive in the order the I/O was initiated. However, in my experience with IOCP servers, I've never encountered out-of-order message delivery.

  • Why doesn't the completion notification order guarantee the sequence of operations?
  • If the completion notifications are not in order, how is the message order still maintained?

I appreciate any insights or explanations that could help clarify these points!

发布评论

评论列表(0)

  1. 暂无评论