replace 3 separate calls to WSAGetLastError() with 1