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 theWSAIoctl
function with theSIO_GET_EXTENSION_FUNCTION_POINTER
opcode specified. The input buffer passed to theWSAIoctl
function must containWSAID_DISCONNECTEX
, a globally unique identifier (GUID) whose value identifies theDisconnectEx
extension function. On success, the output returned by theWSAIoctl
function contains a pointer to theDisconnectEx
function. TheWSAID_DISCONNECTEX
GUID is defined in theMswsock.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.
精彩评论