ARES_SET_SERVERS(3)
π ARES_SET_SERVERS π
okay bestie, we're doing ares_set_servers(3) and ares_set_servers_ports(3) today, and the tea is: these two are deprecated π but you still gotta know them, so let's go. This is a Library Functions Manual situation, and we're talking about initializing name server configuration for an ares channel. (yes, that's the deprecation in the NAME line too, she's not hiding it)
β¨ SYNOPSIS β¨
#include <ares.h>
int ares_set_servers(ares_channel_t *channel,
const struct ares_addr_node *servers)
int ares_set_servers_ports(ares_channel_t *channel,
const struct ares_addr_port_node *servers)
π¦ DESCRIPTION π¦
So like, ares_set_servers(3) initializes the name servers configuration for the channel data that channel points to. Where does it get them from? From servers, which is a pointer to a linked list of ares_addr_node structs holding name server address data. it's giving "here's my whole squad, in order" π
That linked list pointer you pass in? It can totally be the result of a previous call to ares_get_servers(3), or honestly just a linked list of ares_addr_node structs you set up by other means. no judgement, bestie π«Ά
Now ares_set_servers_ports(3) is the extra one β she also lets you specify the UDP and TCP ports to be used for communication, and she does it on a per-server basis. iconic tbh. And same deal: the linked list argument may be the result of a previous call to ares_get_servers_ports(3), or a linked list of ares_addr_port_node structs set up by other means. β¨
heads up, this part matters: this function replaces any potentially previously configured name servers with the ones given in the linked list. so if you want more than one name server on a channel, ALL the ones you want have to be in a single list. one list, everybody in it, periodt.
And, though it's not recommended, passing NULL will clear all configured servers and make an inoperable channel. π It may be advantageous for test simulation, but it's unlikely to be useful in production. so like... test vibes only, don't ship that.
Also important: the function does not take ownership of the linked list argument. The caller is responsible for freeing the linked list when it's no longer needed. that's on you, bestie π
This function is capable of handling IPv4 and IPv6 name server addresses simultaneously, which renders ares_init_options(3) with optmask ARES_OPT_SERVERS functionally obsolete β except for IPv4-only name server usage. we love a glow-up π
And as of v1.22.0, this function can be called on an active channel with running queries. Previously it would return ARES_ENOTIMP. character development fr fr πβ¨
πΈ RETURN VALUES πΈ
ares_set_servers(3) may return any of the following values:
ARES_SUCCESSβ the name servers configuration was successfully initialized. slay πARES_ENOMEMβ the process's available memory was exhausted. rip πARES_ENODATAβ the channel data identified bychannelwas invalid. not the vibe check failing πARES_ENOTINITIALIZEDβ c-ares library initialization not yet performed. you gotta warm her up first bestie π§
π SEE ALSO π
go read these too, iykyk π
π NOTES π
Deprecated functions as of c-ares 1.24.0 due to inability to set all available server options. Use ares_set_servers_csv(3). like genuinely, bestie, use the CSV one. this is your sign π«Ά
β AVAILABILITY β
ares_set_servers(3) was added in c-ares 1.7.1; ares_set_servers_ports(3) was added in c-ares 1.11.0. throwback era honestly πΈ
and that's the whole page, bestie β this one lives in the Library Functions Manual and it's dated 5 March 2010 π go configure responsibly, mwah π β¨
π¦ 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 2010 by Ben Greear <greearb@candelatech.com>
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms