Microsoft KB Archive/222058

{|
 * width="100%"|

INFO: WSAGetLastError Returns 0 Visual Basic on SOCKET_ERROR

 * }

Q222058

-

The information in this article applies to:


 * Microsoft Win32 Software Development Kit (SDK)
 * Microsoft Visual Basic Professional Edition for Windows, versions 4.0, 5.0, 6.0
 * Microsoft Visual Basic Enterprise Edition for Windows, versions 4.0, 5.0, 6.0

-

SUMMARY
When calling Winsock API in Visual Basic, you may run into situations where the socket API calls return SOCKET_ERROR but WSAGetLastError returns 0. This is because Visual Basic retrieves the error code for each API call, sets the error code in Err.LastDllError, and then resets the error to 0.

Whenever there is an API call failure regardless of Winsock API or any other API, you need to retrieve the error code for the API from Err.LastDllError.

Additional query words:

Keywords : kbVBp600 kbWinsock

Issue type : kbinfo

Technology : kbVBSearch kbWin32SDKSearch kbAudDeveloper kbZNotKeyword6 kbZNotKeyword2 kbVB500Search kbVB600Search kbVB500 kbVB600 kbSDKSearch kbVB400Search kbVB400 kbWin32sSearch