ARES_SET_SORTLIST(3)

πŸ“¦
version 1.34.9 Β· 3 versions
, in alpine 3.22, alpine 3.23, alpine 3.24, arch rolling, centos-stream 10, debian trixie, fedora 43, fedora 44, nixos 26.05, nixpkgs unstable, opensuse-leap 16.0, ubuntu noble, ubuntu questing, ubuntu resolute, ubuntu stonking

πŸ’… ARES_SET_SORTLIST β€” the sort your DNS results era

okay bestie, gather round, because this one is from the Library Functions Manual and it is lowkey iconic. We're talking ares_set_sortlist(3), the function that decides what order your addresses come back in. Main character energy fr fr. πŸŽ€


✨ NAME ✨

ares_set_sortlist β€” Initialize an ares_channel_t *sortlist configuration πŸ¦‹


✨ SYNOPSIS ✨

#include <ares.h>

int ares_set_sortlist(ares_channel_t *channel, const char *sortstr)

like, two args, one int, we're literally so back πŸ’…


✨ DESCRIPTION ✨

so the 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) are sorted according to the sortlist. no cap, it's giving custom order πŸ‘‘

The sortstr string you hand it holds a space separated list of IP-address-netmask pairs. The netmask is optional β€” but if it's there, it follows the address after a slash. For example:

"130.155.160.0/255.255.240.0 130.155.0.0"

see how the second one said "no netmask for me, I'm free"? yeah. optional fr.

⚠️ heads up bestie: this function replaces any potentially previously configured address sortlist with the ones given in the configuration string. so if you had a sortlist before, it's gone-gone. bye. πŸ’€

✨ RETURN VALUES ✨

ares_set_sortlist(3) may return any of the following values, and yes we're listing every single one because we don't skip ✨

  • ARES_SUCCESS β€” the sortlist configuration was successfully initialized. slay!! πŸŽ‰
  • ARES_ENOMEM β€” the process's available memory was exhausted. 😭 tragic.
  • ARES_ENODATA β€” the channel data identified by channel was invalid. 🚩
  • ARES_ENOTINITIALIZED β€” c-ares library initialization not yet performed. bestie you gotta init first!! πŸ™ˆ

✨ SEE ALSO ✨

go read those too, iykyk 🫢


✨ AVAILABILITY ✨

ares_set_sortlist(3) was added in c-ares 1.11.0 ⭐


and that's the whole page, bestie πŸ’– this one came from the Library Functions Manual and was dated 23 November 2015 β€” a vintage classic, honestly, still serving looks. now go sort those addresses. periodt. πŸŒˆπŸ’…βœ¨

πŸ“¦ where this page comes from