Name
gai_strerror - network address and service translation
Synopsis
|
const char *
gai_strerror (int ecode);
|
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.
Detailed description
The
gai_strerror
function returns an error message string corresponding to the error code
returned by
getaddrinfo
or
getnameinfo.
The following error codes and their meaning are defined in
|
#include <netdb.h:>
EAI_AGAIN
|
temporary failure in name resolution
|
EAI_BADFLAGS
|
|
invalid value for
ai_flags
|
EAI_BADHINTS
|
|
invalid value for
hints
|
EAI_FAIL
|
non-recoverable failure in name resolution
|
EAI_FAMILY
|
ai_family
not supported
|
EAI_MEMORY
|
memory allocation failure
|
EAI_NONAME
|
hostname
or
servname
not provided, or not known
|
EAI_PROTOCOL
|
|
resolved protocol is unknown
|
EAI_SERVICE
|
servname
not supported for
ai_socktype
|
EAI_SOCKTYPE
|
|
ai_socktype
not supported
|
EAI_SYSTEM
|
system error returned in
errno
|
|
Examples
#include <stdio.h>
#include <netdb.h>
#include <netinet/in.h>
int main()
{
struct addrinfo *result;
char hostname[80];
int error;
if (error = getaddrinfo("www.nokia.com",NULL, NULL, &result))
{
fprintf(stderr, "error using getaddrinfo: %s\n", gai_strerror(error));
}
if (result)
{
if (error = getnameinfo(result->ai_addr, sizeof(struct sockaddr), hostname, sizeof(hostname), NULL,0,0))
{
printf( "error using getnameinfo: %s\n", gai_strerror(error));
}
}
return 0;
}
See also
getaddrinfo,
getnameinfo
Feedback
For additional information or queries on this page send feedback
© 2005-2007 Nokia
|
|