socket() open failed with 10022 (under special conditions)

EDN Admin

Well-known member
Joined
Aug 7, 2010
Messages
12,794
Location
In the Machine
Hi,

I have a problem with running a very simple test program that just opens a socket under special conditions:
- Works in Windows XP on local or Clearcase-Dynamic-View drives
- Works in Win 7 on local drives
- Does not work in Clearcase-Dynamic-View drives in Win7
The problem occurs when calling:
<pre style="font-family:Consolas sock = socket (AF_INET, SOCK_STREAM, 0); It returns INVALID_SOCKET with LastError = 10022 . A simmilar issue was reported at http://social.msdn.microsoft.com/Forums/en-US/wsk/thread/3076a9cd-57a0-418d-8de1-07adc3b486bb but somehow never resolved. I can supply the complete test program/VS 2010 solution if necessary. This is currently our main blocking issue for our Windows XP -> Win7 migration (we heavily depend on using clearcase dynamic views) Is there any solution or workaround known for this?[/code]





example code I used:

<pre style="font-family:Consolas <span style="color:blue #include<span style="color:#a31515 "stdafx.h"<br/><span style="color:blue #include<span style="color:#a31515 <windows.h><br/><span style="color:blue #include<span style="color:#a31515 <winsock.h><br/><span style="color:blue #include<span style="color:#a31515 <stdio.h><span style="color:#a31515 <br/> <span style="color:blue int _tmain(<span style="color:blue int argc, _TCHAR* argv[])<br/>{<br/> WSADATA wsadata;<br/> <span style="color:green //request socket version 2.2<br/> WORD vers = MAKEWORD (2, 2);<br/> <span style="color:blue int ret, sock;<br/> <span style="color:green //initialize windows sockets
ret = WSAStartup (vers, &wsadata);
<span style="color:blue if (ret)
{
fprintf (stderr, <span style="color:#a31515 "WSAStartup failed: rc: %dn", ret);
fprintf (stderr, <span style="color:#a31515 "err: %lun", WSAGetLastError());
<span style="color:blue return 1;
}
<span style="color:blue else
{
printf(<span style="color:#a31515 "WSAStartup succeeded...n");
}


printf(<span style="color:#a31515 "WSA Information:n");
printf(<span style="color:#a31515 "high ver: %d.%d ver: %d.%dn",
HIBYTE(wsadata.wHighVersion),
LOBYTE(wsadata.wHighVersion),
HIBYTE(wsadata.wVersion),
LOBYTE(wsadata.wVersion));
printf(<span style="color:#a31515 "desc: %sn", wsadata.szDescription);
printf(<span style="color:#a31515 "stat: %sn", wsadata.szSystemStatus);
printf(<span style="color:#a31515 "max sock: %d max udp size: %dn", wsadata.iMaxSockets, wsadata.iMaxUdpDg);

<span style="color:green //create a simple socket
sock = socket (AF_INET, SOCK_STREAM, 0);
<span style="color:blue if (sock == INVALID_SOCKET)
{
<span style="color:blue int iErr = WSAGetLastError();
LPVOID lpMsgBuf;
FormatMessage(
FORMAT_MESSAGE_ALLOCATE_BUFFER |
FORMAT_MESSAGE_FROM_SYSTEM |
FORMAT_MESSAGE_IGNORE_INSERTS,
NULL,
iErr,
MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),
(LPTSTR) &lpMsgBuf,
0, NULL );



fprintf (stderr, <span style="color:#a31515 "socket failed: err: %lun %sn", iErr, lpMsgBuf);

LocalFree(lpMsgBuf);
}
<span style="color:blue else
{
fprintf (stderr, <span style="color:#a31515 "socket succeeded: %dn", sock);
closesocket (sock);
}
WSACleanup ();
<span style="color:blue return 0;
} <br/> [/code]
<br/>

View the full article
 
Back
Top