gai_strerror Subroutine

Purpose

Facilitates consistent error information from EAI_* values returned by the getaddrinfo subroutine.

Library

Library (libc.a)

Syntax

#include <sys/socket.h>
#include <netdb.h>
char *
gai_strerror (ecode)
int ecode;
int
gai_strerror_r (ecode, buf, buflen)
int ecode;
char *buf;
int buflen;

Description

For multithreaded environments, the second version should be used. In gai_strerror_r, buf is a pointer to a data area to be filled in. buflen is the length (in bytes) available in buf.

It is the caller's responsibility to insure that buf is sufficiently large to store the requested information, including a trailing null character. It is the responsibility of the function to insure that no more than buflen bytes are written into buf.

Return Values

If successful, a pointer to a string containing an error message appropriate for the EAI_* errors is returned. If ecode is not one of the EAI_* values, a pointer to a string indicating an unknown error is returned.