Winsock Registered I/O 需要包含哪些内容
What includes are needed for Winsock Registered I/O
Winsock Registered I/O需要包含哪些内容?
我正在使用 Windows 10 和 Visual Studio Community 2015 Update3
MSDN Winsock Include Files 是我唯一能找到的,非常 模糊。
这些是我能找到的仅有的 Winsock2 包含:
#include <WinSock2.h>
#include <WS2tcpip.h>
#include <MSWSock.h>
#include <WS2spi.h>
#include <WS2atm.h>
#include <ws2def.h>
#include <ws2ipdef.h>
不幸的是,其中 none 似乎定义了任何 RIO 函数:
RIOCreateCompletionQueue()
RIOCreateRequestQueue()
//and etc are undefined..
据我了解,从 2012 年的 Windows 8.1 开始,这些功能随 Windows SDK 一起提供?
引自 MSDN:
RIOCreateCompletionQueue function
The function pointer to the RIOCreateCompletionQueue
function
must be obtained at run time by making a call to the WSAIoctl
function
with the SIO_GET_MULTIPLE_EXTENSION_FUNCTION_POINTER
opcode specified.
The input buffer passed to the WSAIoctl
function must contain
WSAID_MULTIPLE_RIO
, a globally unique identifier (GUID) whose value
identifies the Winsock registered I/O extension functions. On success,
the output returned by the WSAIoctl
function contains a pointer to the
RIO_EXTENSION_FUNCTION_TABLE
structure that contains pointers to the
Winsock registered I/O extension functions. The
SIO_GET_MULTIPLE_EXTENSION_FUNCTION_POINTER IOCTL
is defined in the
Ws2def.h
header file. The WSAID_MULTIPLE_RIO
GUID is defined in the
Mswsock.h
header file.
另请参阅 this question. A link from that question references this RIO implementation,其中包含以下示例(摘录):
...
inline void CreateRIOSocket()
{
g_s = CreateSocket(WSA_FLAG_REGISTERED_IO);
Bind(g_s, PORT);
InitialiseRIO(g_s);
}
inline SOCKET CreateSocket(
const DWORD flags = 0)
{
g_s = ::WSASocket(
AF_INET,
SOCK_DGRAM,
IPPROTO_UDP,
NULL,
0,
flags);
if (g_s == INVALID_SOCKET)
{
ErrorExit("WSASocket");
}
return g_s;
}
inline void InitialiseRIO(
SOCKET s)
{
GUID functionTableId = WSAID_MULTIPLE_RIO;
DWORD dwBytes = 0;
bool ok = true;
if (0 != WSAIoctl(
s,
SIO_GET_MULTIPLE_EXTENSION_FUNCTION_POINTER,
&functionTableId,
sizeof(GUID),
(void**)&g_rio,
sizeof(g_rio),
&dwBytes,
0,
0))
{
ErrorExit("WSAIoctl");
}
}
...
Winsock Registered I/O需要包含哪些内容? 我正在使用 Windows 10 和 Visual Studio Community 2015 Update3
MSDN Winsock Include Files 是我唯一能找到的,非常 模糊。
这些是我能找到的仅有的 Winsock2 包含:
#include <WinSock2.h>
#include <WS2tcpip.h>
#include <MSWSock.h>
#include <WS2spi.h>
#include <WS2atm.h>
#include <ws2def.h>
#include <ws2ipdef.h>
不幸的是,其中 none 似乎定义了任何 RIO 函数:
RIOCreateCompletionQueue()
RIOCreateRequestQueue()
//and etc are undefined..
据我了解,从 2012 年的 Windows 8.1 开始,这些功能随 Windows SDK 一起提供?
引自 MSDN:
RIOCreateCompletionQueue function
The function pointer to the
RIOCreateCompletionQueue
function must be obtained at run time by making a call to theWSAIoctl
function with theSIO_GET_MULTIPLE_EXTENSION_FUNCTION_POINTER
opcode specified. The input buffer passed to theWSAIoctl
function must containWSAID_MULTIPLE_RIO
, a globally unique identifier (GUID) whose value identifies the Winsock registered I/O extension functions. On success, the output returned by theWSAIoctl
function contains a pointer to theRIO_EXTENSION_FUNCTION_TABLE
structure that contains pointers to the Winsock registered I/O extension functions. TheSIO_GET_MULTIPLE_EXTENSION_FUNCTION_POINTER IOCTL
is defined in theWs2def.h
header file. TheWSAID_MULTIPLE_RIO
GUID is defined in theMswsock.h
header file.
另请参阅 this question. A link from that question references this RIO implementation,其中包含以下示例(摘录):
...
inline void CreateRIOSocket()
{
g_s = CreateSocket(WSA_FLAG_REGISTERED_IO);
Bind(g_s, PORT);
InitialiseRIO(g_s);
}
inline SOCKET CreateSocket(
const DWORD flags = 0)
{
g_s = ::WSASocket(
AF_INET,
SOCK_DGRAM,
IPPROTO_UDP,
NULL,
0,
flags);
if (g_s == INVALID_SOCKET)
{
ErrorExit("WSASocket");
}
return g_s;
}
inline void InitialiseRIO(
SOCKET s)
{
GUID functionTableId = WSAID_MULTIPLE_RIO;
DWORD dwBytes = 0;
bool ok = true;
if (0 != WSAIoctl(
s,
SIO_GET_MULTIPLE_EXTENSION_FUNCTION_POINTER,
&functionTableId,
sizeof(GUID),
(void**)&g_rio,
sizeof(g_rio),
&dwBytes,
0,
0))
{
ErrorExit("WSAIoctl");
}
}
...