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
DisconnectExfunction must be obtained at run time by making a call to theWSAIoctlfunction with theSIO_GET_EXTENSION_FUNCTION_POINTERopcode specified. The input buffer passed to theWSAIoctlfunction must containWSAID_DISCONNECTEX, a globally unique identifier (GUID) whose value identifies theDisconnectExextension function. On success, the output returned by theWSAIoctlfunction contains a pointer to theDisconnectExfunction. TheWSAID_DISCONNECTEXGUID is defined in theMswsock.hheader 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.
加载中,请稍侯......
精彩评论