getaddrinfo TCP UDP

Converts human-readable text strings representing hostnames or IP addresses into a dynamically allocated linked list of struct addrinfo structures.

Files

net_bsd.h/net_bsd.c

Prototype

int  getaddrinfo (const          char       *p_node_name,
                  const          char       *p_service_name,
                  const  struct  addrinfo   *p_hints,
                         struct  addrinfo  **pp_res);

Arguments

p_node_name

A pointer to a string that contains a host (node) name or a numeric host address string. For the Internet protocol, the numeric host address string is a dotted-decimal IPv4 address or an IPv6 hex address.

p_service_name

A pointer to a string that contains either a service name or port number represented as a string.

p_hints

A pointer to an addrinfo structure that provides hints about the type of socket the caller supports.

pp_res

A pointer to a linked list of one or more addrinfo structures that contains response information about the host.

Returned Value

0, if no error,

Most non-zero error codes returned map to the set of errors outlined by Internet Engineering Task Force (IETF) recommendations:

  • EAI_ADDRFAMILY

  • EAI_AGAIN

  • EAI_BADFLAGS

  • EAI_FAIL

  • EAI_FAMILY

  • EAI_MEMORY

  • EAI_NONAME

  • EAI_OVERFLOW

  • EAI_SERVICE

  • EAI_SOCKTYPE

  • EAI_SYSTEM