gai_strerror() — Address and name information error description

Standards

Standards / Extensions C or C++ Dependencies
RFC2553
Single UNIX Specification, Version 3
both z/OS® V1R4

Format

#define _OPEN_SYS_SOCK_IPV6
#include <netdb.h>

char *gai_strerror(int ecode);
SUSV3:
#define _POSIX_C_SOURCE 200112L
#include <netdb.h> 
const char *gai_strerror(int ecode);

General description

The gai_strerror() function returns a pointer to a text string describing the error value returned by a failure return from either the getaddrinfo() or getnameinfo() function. If the ecode is not one of the EAI_xxx values from the <netdb.h> header, then gai_strerror() returns a pointer to a string indicating an unknown error.

Subsequent calls to gai_strerror() will overwrite the buffer containing the text string.

Returned value

When successful, gai_strerror() returns a pointer to a string describing the error. Upon failure, gai_strerror() will return NULL and set errno to one of the following:

Error Code
Description
ENOMEM
Insufficient memory to allocate buffer for text string describing the error.

Related information