Jump to main content

##

# 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

Parameters | Description
--- | ---
node | The name of the server to look up.
service | Unused.
hints | Hints to the function. Currently only ai_family is used. Set to either 0, AF_INET or AF_INET6.
res | Memory 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.