gai_strerror(3)

gai_strerror3

Get error message string from eai_xxx error code

Usage

#include <sys/types.h>

#include <sys/socket.h>

#include <netdb.h>

const char *

gai_strerror(int ecode);

Overview

The gai_strerror() 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⟩:

EAI_ADDRFAMILY

Address family for hostname not supported

EAI_AGAIN

Name could not be resolved at this time

EAI_BADFLAGS

flags parameter had an invalid value

EAI_BADHINTS

invalid value for hints

EAI_FAIL

Non-recoverable failure in name resolution

EAI_FAMILY

Address family was not recognized

EAI_MEMORY

Memory allocation failure

EAI_NODATA

No address associated with hostname

EAI_NONAME

Name does not resolve

EAI_OVERFLOW

argument buffer overflow

EAI_PROTOCOL

Resolved protocol is unknown

EAI_SERVICE

Service was not recognized for socket type

EAI_SOCKTYPE

Intended socket type was not recognized

EAI_SYSTEM

System error returned in errno

Return values

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.

Releases

70 releases since FreeBSD 4.0-RELEASE; the text changed 46 times.

  1. 4.0
  2. 4.1
  3. 4.1.1–4.2
  4. 4.3
  5. 4.4
  6. 4.5
  7. 4.6–4.10
  8. 4.11
  9. 5.0
  10. 5.1
  11. 5.2–5.2.1
  12. 5.3
  13. 5.4–5.5
  14. 6.0–6.3
  15. 6.4
  16. 7.0
  17. 7.1
  18. 7.2
  19. 7.3
  20. 7.4
  21. 8.0
  22. 8.1
  23. 8.2
  24. 8.3
  25. 8.4
  26. 9.0
  27. 9.1
  28. 9.2
  29. 9.3
  30. 10.0
  31. 10.1
  32. 10.2
  33. 10.3
  34. 10.4
  35. 11.0
  36. 11.1
  37. 11.2
  38. 11.3
  39. 11.4
  40. 12.0
  41. 12.1
  42. 12.2
  43. 12.3
  44. 12.4
  45. 13.0–13.1
  46. 13.2
  47. 13.3–16.0

Standards

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.

From base 16.0-CURRENT-20261027-61c70dc16a79 in FreeBSD 16.0-CURRENT (2026-10-27). Parsed by carta from the page's mdoc source.