关于GetQueuedCompletionStatus的返回值



关于GetQueuedCompletionStatus的返回值

MSDN中对GetQueuedCompletionStatus的叙述比较详细,不过对它的返回值,实在有点没看懂,下面是对于GetQueuedCompletionStatus的返回值的介绍(其中的中文翻译是引用的某位网友):

Return Values 


If the function dequeues a completion packet for a successful I/O operation from the completion port, the return value is nonzero. The function stores information in the variables pointed to by the lpNumberOfBytesTransferred, lpCompletionKey, and lpOverlapped parameters. 

如果函数从完成端口的一个成功I/O操作取出一个完成包,返回值为非0。函数在指向lpNumberOfBytesTransferred, lpCompletionKey, and lpOverlapped的参数指针中存储相关信息。  


If *lpOverlapped is NULL and the function does not dequeue a completion packet from the completion port, the return value is zero. The function does not store information in the variables pointed to by the lpNumberOfBytes and lpCompletionKey parameters. To get extended error information, call GetLastError. If the function did not dequeue a completion packet because the wait timed out, GetLastError returns WAIT_TIMEOUT.  

如果 *lpOverlapped为空并且函数没有从完成端口得到完成包,返回值为0,函数则不会再lpNumberOfBytes and lpCompletionKey所指向的参数中存储信息。调用GetLastError可以得到一个扩展信息。如果函数因为等待超时未能得到完成包,GetLastError返回WAIT_TIMEOUT. 


If *lpOverlapped is not NULL and the function dequeues a completion packet for a failed I/O operation from the completion port, the return value is zero. The function stores information in the variables pointed to by lpNumberOfBytes, lpCompletionKey, and lpOverlapped. To get extended error information, call GetLastError.  

如果 *lpOverlapped不为空并且函数从完成端口的一个失败I/O操作得到完成包,返回值为0,函数在指向lpNumberOfBytesTransferred, lpCompletionKey, and lpOverlapped的参数指针中存储相关信息。调用GetLastError可以得到扩展错误信息 


If a socket handle associated with a completion port is closed, GetQueuedCompletionStatus returns ERROR_SUCCESS, with lpNumberOfBytes equal zero. 
 如果一个socket句柄关联到一个完成端口被关闭了,则GetQueuedCompletionStatus返回ERROR_SUCCESS,并且lpNumberOfBytes等于0

---------------------------------------------------------------
对最后的Socket关闭时的叙述,似乎是不对的.应该是此时还是返回非零,但是通过GetLastError得到的值将是ERROR_SUCCESS,,并且lpNumberOfBytes等于0.
也就是说,成功返回一个完成包的时候,返回是非零,并且传入的参数中将存放相应的消息;如果socket被关闭,此时通过GetLastError将得到ERROR_SUCCESS并且lpNumberOfBytes应该为0,这种情况还是认为是成功的.
如果得到的lpOverlapped为空,或是得到一个失败的IO完成包,返回值将为0,...

不知道上面的理解有没有错误?
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值