From the Winsock Reference page, it said:
getaddrinfo function
Return value
Success returns zero. Failure returns a nonzero Windows Sockets error code, as found in the Windows Sockets Error Codes.
Use the gai_strerror function to print error messages based on the EAI codes returned by the getaddrinfo function. The gai_strerror function is provided for compliance with IETF recommendations, but it is not thread safe. Therefore, use of traditional Windows Sockets functions such as WSAGetLastError is recommended.
It said the EAI error codes can be found in the Windows Sockets Error Codes page, but I cannot see any EAI code in that page, such as EAI_AGAIN, EAI_BADFLAGS, etc...
For Windows, the correct way to get the code is to check if getaddrinfo
returns a nonzero value, then call WSAGetLastError
to get the code?