ARES_GET_SERVERS(3)
π ARES_GET_SERVERS(3) π
okay bestie, so this is a page from the Library Functions Manual and it's all about ares_get_servers and ares_get_servers_ports β two lil functions that go digging in your ares_channel to find out which name servers it's been configured with. π heads up tho: they're deprecated (more on that in a sec, don't panic).
β¨ NAME β¨
ares_get_servers, ares_get_servers_ports β Retrieve name servers from an initialized ares_channel (deprecated) π
πΈ SYNOPSIS πΈ
#include <ares.h>
int ares_get_servers(const ares_channel_t *channel,
struct ares_addr_node **servers)
int ares_get_servers_ports(const ares_channel_t *channel,
struct ares_addr_port_node **servers)
π¦ DESCRIPTION π¦
so like, ares_get_servers(3) pulls the name servers configuration out of the channel data that channel points at, and hands it to you as a linked list of ares_addr_node structs β with a pointer to the very first node dropped at the address you passed in servers. it's giving "here's ur lil chain of servers, bestie". β¨
ares_get_servers_ports(3) is the same vibe but extra β it also grabs any per-server port information that might have been configured earlier, and returns a linked list of ares_addr_port structures instead. π₯
the caller may traverse the returned name server linked list, or honestly just use it directly as suitable input for the ares_set_servers(3) / ares_set_servers_ports(3) functions β but shall not shrink or extend the list on its own. do not touch. hands off. π
every single node of that name server linked list lives in memory that's dynamically allocated and managed by c-ares. so it is your responsibility (yes, yours, main character) to free the resulting linked list using ares_free_data(3) once you don't need it anymore. don't leave it hanging, that's so not slay. π«Ά
and the glow-up? this function handles IPv4 and IPv6 name server addresses simultaneously, which lowkey renders ares_save_options(3) with optmask ARES_OPT_SERVERS functionally obsolete β except for IPv4-only name server usage. iykyk. π
π RETURN VALUES π
this function may return any of the following values, bestie, so read carefully:
ARES_SUCCESSβ the name servers configuration was successfully retrieved πARES_ENOMEMβ the memory was exhausted πARES_ENODATAβ the channel data identified bychannelwas invalid. π
π SEE ALSO π
β AVAILABILITY β
ares_get_servers(3)was added in c-ares 1.7.1ares_get_servers_ports(3)was added in c-ares 1.11.0
π NOTES π
as of c-ares 1.24, these functions are deprecated β and it's because of their lack of ability to store the entire server configuration. π use ares_get_servers_csv(3) instead. periodt.
and that's the whole page, babe! π
this one's dated 5 March 2010, it lives in the Library Functions Manual (that's the ARES_GET_SERVERS(3) page title, you already knew that tho), and the source/version line is the same ARES_GET_SERVERS(3) footer energy. go forth, free your linked lists, and slay. π¦πβ¨
π¦ where this page comes from
- alpine 3.22: c-ares-doc 1.34.9-r0 Β· MIT
- alpine 3.23: c-ares-doc 1.34.9-r0 Β· MIT
- alpine 3.24: c-ares-doc 1.34.9-r0 Β· MIT
- arch rolling: c-ares 1.34.9-1 Β· MIT
- centos-stream 10: c-ares-devel 1.34.9-1.el10 Β· MIT
- debian trixie: libc-ares-dev 1.34.5-1+deb13u1 Β· MIT
- fedora 43: c-ares-devel 1.34.5-2.fc43 Β· MIT
- fedora 43: c-ares-devel 1.34.5-2.fc43 Β· MIT
- fedora 43: c-ares-devel 1.34.8-1.fc43 Β· MIT
- fedora 43: c-ares-devel 1.34.8-1.fc43 Β· MIT
- fedora 44: c-ares-devel 1.34.6-3.fc44 Β· MIT
- fedora 44: c-ares-devel 1.34.6-3.fc44 Β· MIT
- fedora 44: c-ares-devel 1.34.8-1.fc44 Β· MIT
- fedora 44: c-ares-devel 1.34.8-1.fc44 Β· MIT
- nixos 26.05: c-ares 1.34.9
- nixpkgs unstable: c-ares 1.34.8
- opensuse-leap 16.0: c-ares-devel 1.34.8-160000.1.1 Β· MIT
- opensuse-leap 16.0: c-ares-devel 1.34.8-160000.1.1 Β· MIT
- opensuse-leap 16.0: c-ares-devel 1.34.8-160000.1.1 Β· MIT
- opensuse-leap 16.0: c-ares-devel 1.34.8-160000.1.1 Β· MIT
- ubuntu questing: libc-ares-dev 1.34.5-1
- ubuntu questing: libc-ares-dev 1.34.5-1ubuntu0.1
- ubuntu resolute: libc-ares-dev 1.34.6-1 Β· MIT
- ubuntu resolute: libc-ares-dev 1.34.6-1ubuntu0.1
- ubuntu resolute: libc-ares-dev 1.34.6-1ubuntu0.2 Β· MIT
- ubuntu stonking: libc-ares-dev 1.34.8-1 Β· MIT
- π the page's license: MIT
- Copyright 1998 by the Massachusetts Institute of Technology
- Copyright (C) 2008-2010 by Daniel Stenberg
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms