ARES_GET_SERVERS(3)
π ARES_GET_SERVERS π
okay bestie, welcome to the ares_get_servers(3) page β and yeah, it's the one with the sister function ares_get_servers_ports. Together they retrieve name servers from an initialized ares_channel. And listenβ¦ they're deprecated π₯² (more on that below, don't skip it).
β¨ 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 ares_get_servers(3) grabs the name servers config out of the channel data you point at with channel, and hands it back to you as a linked list of ares_addr_node structs β with a pointer to the first node sitting at the address you passed as servers. cute, right? π
ares_get_servers_ports(3) does the same thing but it ALSO scoops up any per-server port info that may have been configured before, returning you a linked list of ares_addr_port structures. extra detail, love that for us π
As the caller you've got options: you can walk the returned name server linked list node by node, or you can just yeet it straight in as input for ares_set_servers(3) / ares_set_servers_ports(3). But do NOT shrink or extend the list yourself β that's not your business, bestie π
Every single node of that name server linked list lives in memory that's dynamically allocated and managed by c-ares. So it's your responsibility to free the whole resulting linked list with ares_free_data(3) once you don't need it anymore. not me forgetting to free and leakingβ¦ couldn't be me π
Also iconic: this function handles IPv4 and IPv6 name server addresses at the same time, which makes ares_save_options(3) with optmask ARES_OPT_SERVERS functionally obsolete β except for IPv4-only name server usage. the range, honestly π
β RETURN VALUES β
This function may return any of the following values:
ARES_SUCCESSβ the name servers configuration was successfully retrieved πARES_ENOMEMβ the memory was exhausted πARES_ENODATAβ the channel data identified by channel was invalid.
π¦ SEE ALSO π¦
ares_set_servers(3), ares_init_options(3), ares_save_options(3)
π 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 the reason is lowkey important: they lack the ability to store the entire server configuration. π¬ Use ares_get_servers_csv(3) instead. periodt.
π and that's the whole page, bestie! this one's from the Library Functions Manual, page ARES_GET_SERVERS(3), dated 5 March 2010 β yes she's been around a minute, and yes she's deprecated, we still love her π«Ά bye!! πΈβ¨
π¦ 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