Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: TCP/IP
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.
Posted 27-Jun-12 10:47am
Edited 27-Jun-12 13:42pm
v2
Comments
Wes Aday at 27-Jun-12 17:57pm
   
Try replacing the 0 with IPPROTO_TCP
tom_delorenzo at 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)

  Print Answers RSS
0 Sergey Alexandrovich Kryukov 505
1 OriginalGriff 258
2 ChintanShukla 195
3 Bhavik_Patel 170
4 Richard Deeming 165
0 Sergey Alexandrovich Kryukov 8,688
1 OriginalGriff 7,237
2 CPallini 2,598
3 Richard MacCutchan 2,080
4 Abhinav S 1,888


Advertise | Privacy | Mobile
Web01 | 2.8.140827.1 | Last Updated 27 Jun 2012
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100