Winsock Error 10045

Hi, i thank anyone in advanced with even a hint of what possibly is wrong but i just started using VC++ 2010 and migrated my projects over from VC++ 2008 and now every time i call the winsock2 function recv on a
socket(AF_INET,SOCK_STREAM,IPPROTO_TCP)
i get error 10045 for operation not supported. This never happened when using 2008 any ideas what might be causing this? all help is much appreciated i already have learned from these forums for a few years now and felt its time to join.
http://msdn.microsoft.com/en-us/library/aa924071.aspx
Operation not supported.

Have you called WSAStartup()?
Yes i did, actually all this code was working perfectly fine until i moved it from VC++ 2008 to VC++ 2010 this is what i have for startup before a connection is started. The client and server actually connect fine and send as well, recv is the only issue....

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
WORD wVersionRequested;
	WSADATA wsaData;
	int err;

	wVersionRequested = MAKEWORD(2, 2);

	err = WSAStartup(wVersionRequested, &wsaData);
	if (err != 0)
	{
		MessageBox(NULL,dbStr(err),"WSAStartup Error Code",MB_OK);
		exit(1);
	}

	if (LOBYTE(wsaData.wVersion) != 2 || HIBYTE(wsaData.wVersion) != 2)
	{
        MessageBox(NULL,"Could not find a usable version of Winsock.dll","Startup Error!",MB_OK);
        WSACleanup();
        exit(1);
    }

	ListenSocket = socket(AF_INET,SOCK_STREAM,IPPROTO_TCP);
	sockaddr_in service;

	service.sin_family = AF_INET;
    service.sin_addr.s_addr = inet_addr(IP);
    service.sin_port = htons(PORT);

	if(bind(ListenSocket, (SOCKADDR *) & service, sizeof (service)) == SOCKET_ERROR)
	{
		MessageBox(NULL,"bind() Failed to execute","WSAStartup Error Code",MB_OK);
		exit(1);
	}

	if(listen(ListenSocket,SOMAXCONN) == SOCKET_ERROR)
	{
		MessageBox(NULL,"listen() Failed to execute","WSAStartup Error Code",MB_OK);
		exit(1);
	}
Ok upon further experiments i have discovered it is due to me using MSG_WAITALL as a flag when calling recv, but to my understanding that flag is supposed to be for TCP SOCK_STREAM sockets, any other way to have recv be called until all packets are recieved??
Yes, you use asyncronous sockets.

The standard way is to use select() on a set of handles and it tells you when a socket is ready to be read/written. This is pretty much standard and there's lots of code around.

The most effient way is to use completion ports. It's a bit trick and platform specific. But it's usually wrapped in a library.

I'd recomend using select() because you'll find lots of documentation and code to help you get going.
ok kbw i thank you very much on this, i will give using select() a shot :) at least i know where to come if i get into more issues lol thanks again
Topic archived. No new replies allowed.