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成功完成。

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值