DnsOptions
public
final
class
DnsOptions
extends Object
| java.lang.Object | |
| ↳ | android.net.http.DnsOptions |
A class configuring the 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.
Hostnames can be resolved 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
HTTP networking stack.
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.
getaddrinfois a blocking call which requires dedicating worker threads and makes cancellation impossible (we need to abandon the thread until the call completes)- The
getaddrinfointerface gives no insight into the root cause of failures struct addrinfoprovides 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.
Most configuration in this class is only applicable if the built-in DNS resolver is used.
Summary
Nested classes | |
|---|---|
class |
DnsOptions.Builder
Builder for |
Public methods | |
|---|---|
Boolean
|
getPersistHostCache()
|
Duration
|
getPersistHostCachePeriod()
|
Inherited methods | |
|---|---|
Public methods
getPersistHostCache
public Boolean getPersistHostCache ()
See Builder#setPersistHostCache
| Returns | |
|---|---|
Boolean |
This value may be null. |
getPersistHostCachePeriod
public Duration getPersistHostCachePeriod ()
See Builder#setPersistHostCachePeriod
| Returns | |
|---|---|
Duration |
This value may be null. |
Content and code samples on this page are subject to the licenses described in the Content License. Java and OpenJDK are trademarks or registered trademarks of Oracle and/or its affiliates.
Last updated 2023-03-08 UTC.