IO完成端口和套接字WSARecv() [英] IO Completion Ports and socket WSARecv()

查看:136
本文介绍了IO完成端口和套接字WSARecv()的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图了解IOCP如何与套接字一起工作.我需要了解它们是否是这样工作的:

I am trying to understand how IOCP works with sockets. I need to understand if this is how they work:

我创建了一个完成端口,它只不过是一个队列,当某些操作完成时该队列将接收通知,然后将套接字与之关联,然后处理传入的通知.

I create a completion port, which is nothing but a queue that will receive notifications when some operation completes, and then I associate my socket with it, and then I process incoming notifications.

现在,我想知道这与从套接字接收数据有何关系,所以当我调用WSARecv()时,究竟发生了什么,WSARecv()会在我调用它时立即返回(不阻塞),然后再返回数据到达WSARecv(),我收到一条通知,通知已收到数据?

Now I want to know how this relates to receiving of data from a socket, so when I call WSARecv() what exactly happens, does WSARecv() returns immediately when I call it (does not block) and then later on when data arrives to WSARecv() I get a notification that data were received?

推荐答案

是的,这就是发生的情况.

Yes, this is what happens.

调用WSARecv()时,该函数将立即返回(请注意,必须将其传递给缓冲区以存储接收到的数据).现在,系统将读取从另一端接收到的数据并将其存储在提供的缓冲区中.当系统执行此操作时,它将在完成端口中放置一条通知,以通知您读取操作已完成.

When you call WSARecv(), the function will return immediately (note that you must pass it a buffer to store the received data). Now the system will read the data received from the other end and store it in the supplied buffer. When the system does that, it will place a notification in the completion port to inform you that the read operation has been completed.

这篇关于IO完成端口和套接字WSARecv()的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆