For any given days, I had a problem I have to investigate on MSWINSCK.ocx based on VB6.0.I actualy try to debug it within a console to know what extactly they are doing more details.I found most likely bug within MSWINSCK.ocx regaring an error handling policy. That means MSWINSCK.ocx always check lasterror value on teb just after calling winsock2 does not matter winsock2 api return error or not. in a case of these scenario, user will be able to meet runtime error(xxx) if there was remained any error value on teb. xxx means the last value itself on the teb of thread calling some api call then clear it value.

Debug Log within the console session
0012f19c 22178b28 00000124 000501f8 00000d10 WS2_32!WSAAsyncSelect+0x2 (FPO: [4,1,0])
WARNING: Stack unwind information not available. Following frames may be wrong.
0012f1bc 2217a18d 00000000 00000001 0000003f MSWINSCK!DllGetClassObject+0x6dfb
0012f1e8 2217a11a 0012f430 2217a07d 0012f204 MSWINSCK!DllGetClassObject+0x8460
0012f220 77d14abf 001517a8 00000064 00000004 MSWINSCK!DllGetClassObject+0x83ed
0012f2b0 22174b91 00151090 001517a8 00000000 OLEAUT32!CTypeInfo2::Invoke+0x234 (FPO: [8,23,0])
0012f2e0 22174b28 001516e8 00000043 00151090 MSWINSCK!DllGetClassObject+0x2e64
0012f30c 735d97c8 001516e8 00000043 7358ab38 MSWINSCK!DllGetClassObject+0x2dfb
0012f348 73648e24 00ec0dd4 00000043 7358ab38 MSVBVM60!CalcValue+0x8b
0012f39c 73677986 00ec0dd4 00000043 7358ab38 MSVBVM60!CEcTypeComp::Bind+0xf8
0012f400 73678bce 00ec0dd4 00000043 00000001 MSVBVM60!__vbaVargUnkAddref+0x56
0012f4d0 735c1fb3 00145dd8 0012f4ec 00402231 MSVBVM60!ExVarIndexLdVar+0x1ec
0012f4ec 735c22b4 00402231 0012f5a8 00000002 MSVBVM60!tagAPRINTER::QueryInterface+0x193
0012f504 735c239a 00145e18 0012f5e8 0012f5a8 MSVBVM60!CTL::QueryInterface+0x97
0012f60c 735c28e7 00ec0f9c 00ec020c 00eb4d08 MSVBVM60!CTL::QueryInterface+0x17d
0012f630 73624560 00ec0f9c 00000000 00000000 MSVBVM60!CTL::InternalRelease+0x29
0012f660 735cd0c6 00ec0f9c 000501f0 00002111 MSVBVM60!PictAddSyscolorsToHpal+0xb2
0012f688 735cf855 00ec0f9c 000501f0 00002111 MSVBVM60!MainHwndCreate+0x72
0012f6e4 735ce4a9 000501f0 00002111 00000002 MSVBVM60!ShowMethShow+0xde
0012f708 735cdeea 00ec09f4 0022013e 00000111 MSVBVM60!VBMessageBox+0xc
0012f774 735f2177 00eb53d8 0022013e 00000111 MSVBVM60!MiscStrTok+0x6e
0012f8f4 735cd0c6 00ec09f4 0022013e 00000111 MSVBVM60!Dispatch<ContainedControls>::Dispatch<ContainedControls>+0x3
0012f91c 735cf855 00ec09f4 0022013e 00000111 MSVBVM60!MainHwndCreate+0x72
0012f978 7739b6e3 0022013e 00000111 00000002 MSVBVM60!ShowMethShow+0xde
0012f9a4 7739b874 735cf626 0022013e 00000111 USER32!InternalCallWinProc+0x28
0012fa1c 7739c2d3 00000000 735cf626 0022013e USER32!UserCallWinProcCheckWow+0x151 (FPO: [SEH])
0012fa58 7739c337 00536d08 00536ca0 00000002 USER32!SendMessageWorker+0x4bd (FPO: [5,2,4])
0012fa78 773ace63 0022013e 00000111 00000002 USER32!SendMessageW+0x7f (FPO: [4,0,4])
0012fa90 773ace1c 00564dc0 00000000 00564dc0 USER32!xxxButtonNotifyParent+0x41 (FPO: [2,0,0])
0012faac 773ace0f 0014fa78 00000001 00000000 USER32!xxxBNReleaseCapture+0xf8 (FPO: [2,0,4])
0012fb30 773acedc 00564dc0 00000202 00000000 USER32!ButtonWndProcWorker+0x6d5 (FPO: [5,26,0])
0012fb50 7739b6e3 000501f0 00000202 00000000 USER32!ButtonWndProcA+0x5d (FPO: [4,0,4])
0012fb7c 7739b874 773ace90 000501f0 00000202 USER32!InternalCallWinProc+0x28
0012fbf4 7739bfce 00000000 773ace90 000501f0 USER32!UserCallWinProcCheckWow+0x151 (FPO: [SEH])
0012fc24 773b0463 773ace90 000501f0 00000202 USER32!CallWindowProcAorW+0x98 (FPO: [6,0,0])
0012fc44 735cd2ff 773ace90 000501f0 00000202 USER32!CallWindowProcA+0x1b (FPO: [5,0,0])
0012fcb0 73624836 00eb4d08 000501f0 00000202 MSVBVM60!_MainClose+0x21
0012fcd8 735cd0c6 00ec0f9c 000501f0 00000202 MSVBVM60!_PictCreateDIBPalette+0x185
0012fd00 735cf855 00ec0f9c 000501f0 00000202 MSVBVM60!MainHwndCreate+0x72
0012fd5c 7739b6e3 000501f0 00000202 00000000 MSVBVM60!ShowMethShow+0xde
0012fd88 7739b874 735cf626 000501f0 00000202 USER32!InternalCallWinProc+0x28

kd> uf 22178b28
22178b28 33c9 xor ecx,ecx
check retuned value by calling WS2_32!WSAAsyncSelect(). returned value is zero at a moment. that measn no error occured.
22178b2a 83f8ff cmp eax,0FFFFFFFFh
22178b2d 0f95c1 setne cl
22178b30 8bf9 mov edi,ecx
22178b32 85ff test edi,edi
22178b34 7507 jne MSWINSCK!DllGetClassObject+0x6e10 (22178b3d)

22178b36 8b06 mov eax,dword ptr [esi]
22178b38 8bce mov ecx,esi
22178b3a ff502c call dword ptr [eax+2Ch]

22178b3d 8bc7 mov eax,edi
22178b3f 5f pop edi
22178b40 5e pop esi
22178b41 5d pop ebp
22178b42 c21000 ret 10h

kd> g @$ra
001b:22178b28 33c9 xor ecx,ecx
kd> r
eax=00000000 ebx=00000000 ecx=0015d568 edx=7c8285ec esi=0015aeb8 edi=00000001
eip=22178b28 esp=0012f1b4 ebp=0012f1bc iopl=0 nv up ei pl zr na pe nc
cs=001b ss=0023 ds=0023 es=0023 fs=003b gs=0000 efl=00000246
001b:22178b28 33c9 xor ecx,ecx

kd> uf .
2217a18d 53 push ebx
2217a18e 8bce mov ecx,esi
eventually this call leads to kernel32!GetLastError() through WS2_32!WSAGetLastError().
2217a190 e81ff6ffff call MSWINSCK!DllGetClassObject+0x7a87 (221797b4)
2217a195 8b86f8000000 mov eax,dword ptr [esi+0F8h]
2217a19b 3bc3 cmp eax,ebx
2217a19d 7530 jne MSWINSCK!DllGetClassObject+0x84a2 (2217a1cf)

2217a19f 399e04010000 cmp dword ptr [esi+104h],ebx
2217a1a5 c7862001000001000000 mov dword ptr [esi+120h],1
2217a1af 7517 jne MSWINSCK!DllGetClassObject+0x849b (2217a1c8)

2217a1b1 8b8ef0000000 mov ecx,dword ptr [esi+0F0h]
2217a1b7 8d45fc lea eax,[ebp-4]
2217a1ba 50 push eax
2217a1bb 8d45f8 lea eax,[ebp-8]
2217a1be 50 push eax
2217a1bf 53 push ebx
2217a1c0 895df8 mov dword ptr [ebp-8],ebx
2217a1c3 e80feeffff call MSWINSCK!DllGetClassObject+0x72aa (22178fd7)

2217a1c8 33c0 xor eax,eax

2217a1ca 5f pop edi
2217a1cb 5e pop esi
2217a1cc 5b pop ebx
2217a1cd c9 leave
2217a1ce c3 ret

2217a1cf 668b8ef8000000 mov cx,word ptr [esi+0F8h]
2217a1d6 8b16 mov edx,dword ptr [esi]
2217a1d8 53 push ebx
2217a1d9 0d00000a80 or eax,800A0000h
2217a1de 51 push ecx
2217a1df 50 push eax
2217a1e0 8bce mov ecx,esi
2217a1e2 899e20010000 mov dword ptr [esi+120h],ebx
2217a1e8 ff5230 call dword ptr [edx+30h]
2217a1eb ebdd jmp MSWINSCK!DllGetClassObject+0x849d (2217a1ca)

kd> t
001b:221797b4 55 push ebp
kd> p
001b:221797b5 8bec mov ebp,esp
kd> p
001b:221797b7 51 push ecx
kd> p
001b:221797b8 56 push esi
kd> p
001b:221797b9 8bf1 mov esi,ecx
kd> p
001b:221797bb e88c710000 call MSWINSCK!DllUnregisterServer+0x54aa (2218094c)

kd> u 2218094c
2218094c ff2510101722 jmp dword ptr [MSWINSCK+0x1010 (22171010)]
22180952 ff2508101722 jmp dword ptr [MSWINSCK+0x1008 (22171008)]
22180958 ff250c101722 jmp dword ptr [MSWINSCK+0x100c (2217100c)]
2218095e ff2580101722 jmp dword ptr [MSWINSCK+0x1080 (22171080)]
22180964 ff2574101722 jmp dword ptr [MSWINSCK+0x1074 (22171074)]
2218096a ff257c101722 jmp dword ptr [MSWINSCK+0x107c (2217107c)]
22180970 ff2578101722 jmp dword ptr [MSWINSCK+0x1078 (22171078)]
22180976 ff2568101722 jmp dword ptr [MSWINSCK+0x1068 (22171068)]
kd> dps 22171010 L1
22171010 71c02425 WS2_32!WSAGetLastError

Global Escalation Manager Tokyo