1.1.24.16 getaddrinfo

C

int getaddrinfo(const char *host, const char *serv, const struct addrinfo *hint, struct addrinfo **res)

Description

Network address and service translation.

Parameters

ParametersDescription
hostPointer to host to translate.
servPointer to service to translate, currently ignored.
hintHint to affect the translation.
resPointer to results pointer.

Returns

  • EAI_NONAME - The node or service is not known.

  • EAI_AGAIN - The name server returned a temporary failure indication. Try again later.

  • EAI_SYSTEM - Other system error; errno is set to indicate the error.

  • EAI_MEMORY - Out of memory.

  • EAI_SERVICE - The requested service is not available for the requested socket type.

Remarks

errnoDescription
EFAULTSystem fault.
EBADMSGBad message.

The getaddrinfo() function allocates and initializes a linked list of addrinfo structures, one for each network address that matches node and service, subject to any restrictions imposed by hints, and returns a pointer to the start of the list in res. The items in the linked list are linked by the ai_next field.

The freeaddrinfo() function frees the memory that was allocated for the dynamically allocated linked list res.