public final class **DnsOptions** extends Object  
A class configuring Cronet's host resolution functionality. Note that while we refer to `DNS` as the most common mechanism being used for brevity, settings apply to other means of
resolving hostnames like hosts file resolution.

Cronet resolve hostnames in two ways - either by using the system resolver (using `getaddrinfo` provided by system libraries), or by using a custom resolver which is built into the
networking stack Cronet uses.

The built-in stack provides several advantages over using the system resolver:

- It has been tailored to the needs of the networking stack, particularly speed and stability.
- `getaddrinfo` is a blocking call which requires dedicating worker threads and makes cancellation impossible (we need to abandon the thread until the call completes)
- The `getaddrinfo` interface gives no insight into the root cause of failures
- `struct addrinfo` provides no TTL (Time To Live) of the returned addresses. This restricts flexibility of handling caching (e.g. allowing the use of stale DNS records) and requires us to either rely on OS DNS caches, or be extremely conservative with the TTL.
- As part of the OS, `getaddrinfo` evolves slowly. Using a custom stack enables Cronet to introduce features like encrypted DNS faster.

Most configuration in this class is only applicable if the built-in DNS resolver is used.  

### Nested Class Summary

|------------|---|---|---------------------------------------------------------------------------------------------------------------------------------|
| class      | [DnsOptions.Builder](https://developer.android.com/develop/connectivity/cronet/reference/org/chromium/net/DnsOptions.Builder.html) || Builder for [DnsOptions](https://developer.android.com/develop/connectivity/cronet/reference/org/chromium/net/DnsOptions.html). |
| @interface | [DnsOptions.Experimental](https://developer.android.com/develop/connectivity/cronet/reference/org/chromium/net/DnsOptions.Experimental.html) || An annotation for APIs which are not considered stable yet.                                                                     |
| class      | [DnsOptions.StaleDnsOptions](https://developer.android.com/develop/connectivity/cronet/reference/org/chromium/net/DnsOptions.StaleDnsOptions.html) || A class configuring Cronet's stale DNS functionality.                                                                           |

### Public Method Summary

|----------------------------------------------------------------------------------------------------------------------------------------------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| static [DnsOptions.Builder](https://developer.android.com/develop/connectivity/cronet/reference/org/chromium/net/DnsOptions.Builder.html)          | [builder](https://developer.android.com/develop/connectivity/cronet/reference/org/chromium/net/DnsOptions.html#builder())()                                                                         |
| Boolean                                                                                                                                            | [getEnableStaleDns](https://developer.android.com/develop/connectivity/cronet/reference/org/chromium/net/DnsOptions.html#getEnableStaleDns())()                                                     |
| Boolean                                                                                                                                            | [getPersistHostCache](https://developer.android.com/develop/connectivity/cronet/reference/org/chromium/net/DnsOptions.html#getPersistHostCache())()                                                 |
| Long                                                                                                                                               | [getPersistHostCachePeriodMillis](https://developer.android.com/develop/connectivity/cronet/reference/org/chromium/net/DnsOptions.html#getPersistHostCachePeriodMillis())()                         |
| Boolean                                                                                                                                            | [getPreestablishConnectionsToStaleDnsResults](https://developer.android.com/develop/connectivity/cronet/reference/org/chromium/net/DnsOptions.html#getPreestablishConnectionsToStaleDnsResults())() |
| [DnsOptions.StaleDnsOptions](https://developer.android.com/develop/connectivity/cronet/reference/org/chromium/net/DnsOptions.StaleDnsOptions.html) | [getStaleDnsOptions](https://developer.android.com/develop/connectivity/cronet/reference/org/chromium/net/DnsOptions.html#getStaleDnsOptions())()                                                   |
| Boolean                                                                                                                                            | [getUseBuiltInDnsResolver](https://developer.android.com/develop/connectivity/cronet/reference/org/chromium/net/DnsOptions.html#getUseBuiltInDnsResolver())()                                       |

### Inherited Method Summary

From class java.lang.Object  

|------------------|---------------------------|
| Object           | clone()                   |
| boolean          | equals(Object arg0)       |
| void             | finalize()                |
| final Class\<?\> | getClass()                |
| int              | hashCode()                |
| final void       | notify()                  |
| final void       | notifyAll()               |
| String           | toString()                |
| final void       | wait(long arg0, int arg1) |
| final void       | wait(long arg0)           |
| final void       | wait()                    |

## Public Methods

#### public static [DnsOptions.Builder](https://developer.android.com/develop/connectivity/cronet/reference/org/chromium/net/DnsOptions.Builder.html)
**builder**
()

<br />

#### public Boolean
**getEnableStaleDns**
()

<br />

#### public Boolean
**getPersistHostCache**
()

<br />

#### public Long
**getPersistHostCachePeriodMillis**
()

<br />

#### public Boolean
**getPreestablishConnectionsToStaleDnsResults**
()

<br />

#### public [DnsOptions.StaleDnsOptions](https://developer.android.com/develop/connectivity/cronet/reference/org/chromium/net/DnsOptions.StaleDnsOptions.html)
**getStaleDnsOptions**
()

<br />

#### public Boolean
**getUseBuiltInDnsResolver**
()

<br />