Sign in to follow this  
Erik Rufelt

ConnectEx / DisconnectEx (EDITED)

Recommended Posts

Erik Rufelt    5901
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;

WSAStartup(0x0202, &wsaData);

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 this post


Link to post
Share on other sites
rmsimpson    228
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


Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this