getaddrinfo Function

C

int getaddrinfo(
    const char * node, 
    const char * service, 
    const struct addrinfo * hints, 
    struct addrinfo ** res
);

Description

This function deprecates gethostbyname(). It handles both IPv4 and IPv6.

Preconditions

The MPLAB Harmony DNS client services must be active.

Parameters

ParametersDescription
nodeThe name of the server to look up.
serviceUnused.
hintsHints to the function. Currently only ai_family is used. Set to either 0, AF_INET or AF_INET6.
resMemory location of where the results are. Results must be freed with free addrinfo.

Returns

  • 0 - If function is successful.

  • EAI_NONAME - When no name could be found.

  • EAI_FAIL - When a failure has occurred.

  • EAI_AGAIN - When the look-up is in progress. Call the function again later to check the results.

Remarks

None.