ares_set_servers_csv, ares_set_servers_ports_csv - Set list of DNS servers to be used.


#include <ares.h>
int ares_set_servers_csv(ares_channel_t *channel, const char* servers)
int ares_set_servers_ports_csv(ares_channel_t *channel, const char* servers)


The ares_set_servers_csv and ares_set_servers_ports_csvfunctions set the list of DNS servers that ARES will query. As of v1.22.0 this function can be called on an active channel with running queries, previously it would return ARES_ENOTIMP.

Though not recommended, passing NULL for servers will clear all configured servers and make an inoperable channel, this may be advantageous for test simulation but unlikely to be useful in production.

The format of the servers option is:


For example:,,

The ares_set_servers_csv function will ignore any port values specified in the input string, whereare the ares_set_servers_ports_csv function will apply any specified port values as the UDP and TCP port to be used for that particular nameserver.

Return values

ares_set_servers_csv This function may return any of the following values:

ARES_SUCCESS The name servers configuration was successfully initialized.

ARES_ENOMEM The process's available memory was exhausted.

ARES_ENODATA The channel data identified by channel was invalid.

ARES_ENOTINITIALIZED c-ares library initialization not yet performed.

See also



ares_set_servers_csv was added in c-ares 1.7.2; ares_set_servers_ports_csv was added in c-ares 1.11.0.


Ben Greear

This HTML page was made with roffit.