TIP 4: I/O completion packet queuing behavior. I/O完成包的队列行为

 
TIP 4: I/O completion packet queuing behavior.

The order in which I/O completion packets are queued in the IOCP is not necessarily the same order the Winsock2 I/O calls were made. Additionally, if a Winsock2 I/O call returns SUCCESS or IO_PENDING, it is guaranteed that a completion packet will be queued to the IOCP when the I/O completes, regardless of whether the socket handle is closed. After you close a socket handle, future calls to WSASend, WSASendTo, WSARecv, or WSARecvFrom will fail with a return code other than SUCCESS or IO_PENDING, which will not generate a completion packet. The status of the completion packet retrieved by GetQueuedCompletionStatus for I/O previously posted could indicate a failure in this case.

If you delete the IOCP itself, no more I/O can be posted to the IOCP because the IOCP handle itself is invalid. However, the system's underlying IOCP kernel structures do not go away until all successfully posted I/Os are completed.

  在IO完成端口中被排队存取的I/O完成包通知的队列顺序,不一定和Winsock2的I/O调用顺序相同,此外,如果Winsock 2 I/O的调用返回了SUCCESS或者是IO_PENDING,那么它保证当I/O完成的时候,一个完成包会被放入队列中,不管socket句柄是否被关闭都是如此,在你关闭一个套接字句柄之后,WSASend, WSASendTo, WSARecv,或者WSARecvFrom的后续调用将失败,返回代码是除了SUCCESS或IO_PENDING之外的代码,也不会产生任何一个完成包通知。通过GetQueuedCompletionStatus取得先前投递的操作完成包的状态可以指出这种情况的失败。

 
如果你删除IOCP本身,没有更多的I/O能够投递到这个IOCP,因为IOCP句柄自身已经无效了,然而系统底层IOCP内核将不会停止,直到所有已经投递的I/O成功完成。

 

你可能感兴趣的:(IO,socket,delete,System,Go)