Manual Page Search Parameters

GAI_STRERROR(3) Library Functions Manual GAI_STRERROR(3)

gai_strerrorget error message string from EAI_xxx error code

#include <sys/types.h>
#include <sys/socket.h>
#include <netdb.h>

const char *
gai_strerror(int ecode);

The () function returns an error message string corresponding to the error code returned by getaddrinfo(3) or getnameinfo(3).

The following error codes and their meaning are defined in <netdb.h>:

Address family for hostname not supported
Name could not be resolved at this time
flags parameter had an invalid value
invalid value for hints
Non-recoverable failure in name resolution
Address family was not recognized
Memory allocation failure
No address associated with hostname
Name does not resolve
argument buffer overflow
Resolved protocol is unknown
Service was not recognized for socket type
Intended socket type was not recognized
System error returned in errno

The gai_strerror() function returns a pointer to the error message string corresponding to ecode. If ecode is out of range, an implementation-specific error message string is returned.

getaddrinfo(3), getnameinfo(3)

RFC 3493
Basic Socket Interface Extensions for IPv6

EAI_ADDRFAMILY and EAI_NODATA were in previous RFCs, but not in RFC 3493. They are not in POSIX (IEEE Std 1003.1-2017). They were in FreeBSD before 5.2, and were re-added for 14.0. EAI_BADHINTS, EAI_OVERFLOW, and EAI_PROTOCOL are not in RFC 3493 or POSIX.

November 2, 2022 dev