使用 Win8.1 和 Visual Studio 2013,我测试了我能找到的每个 Windows 注册 I/O 示例(大约 5 个)。所有结果都导致 RioCreateRequestQueue() 出现错误 10045,如下图所示。
c:>rioServerTest.exe
InitialiseRio Start
InitialiseRio End
CreateCompletionQueue Start
CreateCompletionQueue End
CreateRequestQueue start
RIOCreateRequestQueue Error: 10045
相关代码为:
void *pContext = 0;
printf("CreateRequestQueue start\n");
g_requestQueue = g_rio.RIOCreateRequestQueue(
g_socket, // Socket
(ULONG) 10, // MaxOutstandingReceive,
(ULONG) 1, // maxReceiveDataBuffers,
(ULONG) 10, // MaxOutstandingSend,
(ULONG) 1, // MaxSendDataBuffers
g_completionQueue, // ReceiveCQ
g_completionQueue, // SendCQ
pContext); // SocketContect
if (g_requestQueue == RIO_INVALID_RQ) {
printf_s("RIOCreateRequestQueue Error: %d\n", GetLastError());
exit(1);
}
printf("CreateRequestQueue End\n");
根据我阅读的文献,Registered I/O 适用于 Windows 8 及更高版本以及 Windows Server 2012 及更高版本。
任何人都可以通过示例向我解释如何让它在 Win8.1 上运行吗?时间差
最佳答案
10045是 WSAEOPNOTSUPP
,其描述是 “不支持操作。
引用的对象类型不支持尝试的操作。这通常发生在不支持此操作的套接字的套接字描述符试图接受数据报套接字上的连接时。”
所以实际上我们需要查看的代码很可能实际上就是您创建套接字的地方。
您的套接字创建代码应如下所示:
socket = ::WSASocket(
AF_INET,
SOCK_DGRAM,
IPPROTO_UDP,
NULL,
0,
WSA_FLAG_REGISTERED_IO);
我有一些示例文章(包括一整套 RIO、UDP 服务器设计和完整的源代码)here ,所有这些都可以在 RIO 支持的所有操作系统上运行。
关于c++ - Windows 注册 I/O Win 8.1 RioCreateRequestQueue 错误 10045,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25788382/