Click here to Skip to main content
15,065,644 members
Please Sign up or sign in to vote.
4.00/5 (1 vote)
See more:
I have the following code that has worked just fine up until Windows 7 (64 bit addressing):

int                 addr_fam = AF_INET; /* AF_INET6 behaves the same */
int                 socket_type = SOCK_STREAM;
SOCKET              conn_socket;

conn_socket = socket(addr_fam, socket_type, 0); /* Open a socket */

Currently, conn_socket is set to -1 and using WSAGetLastError() and FormatMessage I get the message "An invalid argument was supplied".

I have found nothing to suggest that this is all of a sudden an invalid combination of arguments but apparently, at least in my case, it is.

Does anyone have any insight into why this would be the case? Any idea how I can determine which of the 3 arguments the system thinks is invalid?

*** NEW INFO ***
This only occurs in DevStudio while in debug mode. The Release version of the code still works OK.
Updated 27-Jun-12 13:42pm
[no name] 27-Jun-12 17:57pm
Try replacing the 0 with IPPROTO_TCP
tom_delorenzo 27-Jun-12 18:41pm
Unfortunately, I get the same result when IPPROTO_TCP replaces the 0 as 3rd argument to socket.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900