Skip to content
Snippets Groups Projects
Commit f0b8de9e authored by rswindell's avatar rswindell
Browse files

socket_strerror() needs to auto-correct for WinSock error ranges.

parent b299c7d1
No related branches found
No related tags found
No related merge requests found
......@@ -507,6 +507,8 @@ DLLEXPORT char* socket_strerror(int error_number, char* buf, size_t buflen)
#if defined(_WINSOCKAPI_)
strncpy(buf, "Unknown error", buflen);
buf[buflen - 1] = 0;
if(error_number > 0 && error_number < WSABASEERR)
error_number += WSABASEERR;
FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS | FORMAT_MESSAGE_MAX_WIDTH_MASK, // dwFlags
NULL, // lpSource
error_number, // dwMessageId
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment