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!