ARES\_SET\_SORTLIST(3) Library Functions Manual ARES\_SET\_SORTLIST(3)

# [NAME](#NAME)

ares\_set\_sortlist - Initialize an ares\_channel\_t \*sortlist configuration

# [SYNOPSIS](#SYNOPSIS)

```
#include <ares.h>
int ares_set_sortlist(ares_channel_t *channel, const char *sortstr)
```

# [DESCRIPTION](#DESCRIPTION)

The [**ares\_set\_sortlist(3)**](/man/os/c-ares/ares_set_sortlist.3) function initializes an address sortlist configuration for the channel data identified by *channel*, so that addresses returned by [**ares\_gethostbyname(3)**](/man/os/c-ares/ares_gethostbyname.3) are sorted according to the sortlist. The provided *sortstr* string that holds a space separated list of IP-address-netmask pairs. The netmask is optional but follows the address after a slash if present. For example, "130.155.160.0/255.255.240.0 130.155.0.0".

This function replaces any potentially previously configured address sortlist with the ones given in the configuration string.

# [RETURN VALUES](#RETURN_VALUES)

[**ares\_set\_sortlist(3)**](/man/os/c-ares/ares_set_sortlist.3) may return any of the following values:

[**ARES\_SUCCESS**](#ARES_SUCCESS)

The sortlist configuration was successfully initialized.

[**ARES\_ENOMEM**](#ARES_ENOMEM)

The process's available memory was exhausted.

[**ARES\_ENODATA**](#ARES_ENODATA)

The channel data identified by *channel* was invalid.

[**ARES\_ENOTINITIALIZED**](#ARES_ENOTINITIALIZED)

c-ares library initialization not yet performed.

# [SEE ALSO](#SEE_ALSO)

[**ares\_init\_options**(3)](/man/os/c-ares/ares_init_options.3), [**ares\_dup**(3)](/man/os/c-ares/ares_dup.3)

# [AVAILABILITY](#AVAILABILITY)

[ares\_set\_sortlist(3)](/man/os/c-ares/ares_set_sortlist.3) was added in c-ares 1.11.0

23 November 2015

---

Document: ares_set_sortlist(3) from c-ares 1.34.9-r0 (Chainguard OS)
Source: https://github.com/c-ares/c-ares
