# ConnectEx / DisconnectEx (EDITED)

This topic is 5252 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

Hi, Im trying to use the AcceptEx / ConnectEx / DisconnectEx functions in WinSock2. I've tried loading them with WSAIoctl, and it works fine for AcceptEx, but ConnectEx / DisconnectEx gives me an error: WSAEOPNOTSUPP 10045L The attempted operation is not supported for the type of object referenced. I guess for some reason it's not supported for the socket I try to load it for. I'm using Windows XP Pro SP2. code:
SOCKET s;
GUID GuidAcceptEx = WSAID_ACCEPTEX;
int iRet;
DWORD dwBytes;
LPFN_ACCEPTEX lpfnAcceptEx;

s = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP);

iRet = WSAIoctl(
s,
SIO_GET_EXTENSION_FUNCTION_POINTER,
&GuidAcceptEx,
sizeof(GUID),
&lpfnAcceptEx,
sizeof(LPFN_ACCEPTEX),
&dwBytes,
NULL,
NULL);
if(iRet == SOCKET_ERROR)
printf("AcceptEx: %d\n", WSAGetLastError());


That one works, but if I try the same for DisconnectEx or ConnectEx I get error 10045. Do I need to do something else with the socket before I can load all the functions? I've read all the MSDN pages and googled for it but I find the same code and the same documentation everywhere, but it doesn't work for me, and I can't seem to find what I'm doing wrong or why it wouldn't work =) I have tried binding the socket first also, as well as connecting it and a few other things.. MSDN says the functions are all available in Windows XP. EDIT2: It seems I dont even have to load the AcceptEx function since it already has a prototype in MSWsock.h and I can link to it in mswsock.lib. /Erik [Edited by - Erik Rufelt on June 4, 2005 5:01:22 PM]

##### Share on other sites
The actual arguments for socket() and ioctl() are probably quite relevant for this question.

##### Share on other sites
LPFN_CONNECTEX fnConnectEx = NULL;
GUID gufn = WSAID_CONNECTEX;
DWORD dwBytes;

WSAIoctl(m_hSocket, SIO_GET_EXTENSION_FUNCTION_POINTER, &gufn, sizeof(gufn), &fnConnectEx, sizeof(fnConnectEx), &dwBytes, NULL, NULL);

I haven't tried it on XP recently, but it worked for me on Win2003

Robert

• ### Game Developer Survey

We are looking for qualified game developers to participate in a 10-minute online survey. Qualified participants will be offered a \$15 incentive for your time and insights. Click here to start!

• 11
• 15
• 21
• 26
• 11