---
name: "ares_save_options"
section: "3"
platform: "linux"
package: "c-ares"
version: "1.34.9-1"
release: "Arch Linux 2026-11-01"
platforms: ["linux"]
url: "https://new.carta.tech/ares_save_options"
---

# ares\_save\_options(3)

Save configuration values obtained from initialized ares\_channel

## NAME

ares\_save\_options - Save configuration values obtained from initialized ares\_channel

## SYNOPSIS

```
#include <ares.h>
int ares_save_options(const ares_channel_t *channel,
                      struct ares_options *options, int *optmask)
```

## DESCRIPTION

The **[ares\_save\_options(3)](/ares_save_options/3.md)** function saves the channel data identified by *channel*, into the options struct identified by *options*, and saves the mask of options which are set to the integer pointer (passed by reference) identified by *optmask*.

The resultant options and optmask are then able to be passed directly to ares\_init\_options.  When the options are no longer needed, ares\_destroy\_options should be called to free any associated memory.

## RETURN VALUES

**[ares\_save\_options(3)](/ares_save_options/3.md)** can return any of the following values:

- **ARES\_SUCCESS**

  The channel data was successfully stored

- **ARES\_ENOMEM**

  The memory was exhausted

- **ARES\_ENODATA**

  The channel data identified by *channel* were invalid.

## NOTE

Since c-ares 1.6.0 the ares\_options struct has been "locked" meaning that it won't be extended to cover new functions. This function will remain functioning, but it can only return config data that can be represented in this config struct, which may no longer be the complete set of config options. **[ares\_dup(3)](/ares_dup/3.md)** will not have that restriction.

The ares\_options struct can not handle potential IPv6 name servers the ares channel might be configured to use. The **[ares\_save\_options(3)](/ares_save_options/3.md)** function will only return IPv4 servers, if any. In order to retrieve all name servers an ares channel might be using, the **[ares\_get\_servers(3)](/ares_get_servers/3.md)** function must be used instead.

## SEE ALSO

[**ares\_destroy\_options**(3)](/ares_destroy_options/3.md), [**ares\_init\_options**(3)](/ares_init_options/3.md), [**ares\_get\_servers**(3)](/ares_get_servers/3.md), [**ares\_dup**(3)](/ares_dup/3.md)

## AVAILABILITY

[ares\_save\_options(3)](/ares_save_options/3.md) was added in c-ares 1.4.0
