开发者

Windows API: Undefined reference to DisconnectEx

I'm developing an application that uses windows sockets. My socket class has a method named Disconnect that uses DisconnectEx, but i get the following error at linking time:

undefined reference to `DisconnectEx@16'

I'm using MinGW and i'm linking my application with the following libs:

-lws2_32 -lwsock32 -lmswsock

On msdn says that the minimum version required for this function is Windows XP or Windows Server 2003, so i defined WINVER with 0x0502, but i still get the same error.

What i'm missing 开发者_StackOverflow中文版here?

Thanks in advance!


What you apparently missed is this note in the MSDN documentation for the DisconnectEx() function:

Note: The function pointer for the DisconnectEx function must be obtained at run time by making a call to the WSAIoctl function with the SIO_GET_EXTENSION_FUNCTION_POINTER opcode specified. The input buffer passed to the WSAIoctl function must contain WSAID_DISCONNECTEX, a globally unique identifier (GUID) whose value identifies the DisconnectEx extension function. On success, the output returned by the WSAIoctl function contains a pointer to the DisconnectEx function. The WSAID_DISCONNECTEX GUID is defined in the Mswsock.h header file.

Note that the MSDN documentation for DisconnectEx() doesn't specify a library under the Requirements section. That implies that you have to load this function dynamically at runtime via the WSAIoctl()function to obtain a function pointer.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜