DnsOptions
Stay organized with collections
Save and categorize content based on your preferences.
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.
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
Boolean
getEnableStaleDns
()
public
Boolean
getPersistHostCache
()
public
Long
getPersistHostCachePeriodMillis
()
public
Boolean
getPreestablishConnectionsToStaleDnsResults
()
public
Boolean
getUseBuiltInDnsResolver
()
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-10-26 UTC.
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Missing the information I need","missingTheInformationINeed","thumb-down"],["Too complicated / too many steps","tooComplicatedTooManySteps","thumb-down"],["Out of date","outOfDate","thumb-down"],["Samples / code issue","samplesCodeIssue","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2023-10-26 UTC."],[],[],null,["# DnsOptions\n\npublic final class **DnsOptions** extends Object \nA 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\nresolving hostnames like hosts file resolution.\n\nCronet 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\nnetworking stack Cronet uses.\n\nThe built-in stack provides several advantages over using the system resolver:\n\n- It has been tailored to the needs of the networking stack, particularly speed and stability.\n- `getaddrinfo` is a blocking call which requires dedicating worker threads and makes cancellation impossible (we need to abandon the thread until the call completes)\n- The `getaddrinfo` interface gives no insight into the root cause of failures\n- `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.\n- As part of the OS, `getaddrinfo` evolves slowly. Using a custom stack enables Cronet to introduce features like encrypted DNS faster.\n\nMost configuration in this class is only applicable if the built-in DNS resolver is used. \n\n### Nested Class Summary\n\n|------------|---|---|-----------------------------------------------------------------------------------|\n| class | [DnsOptions.Builder](../../../../reference/org/chromium/net/DnsOptions.Builder.html) || Builder for [DnsOptions](../../../../reference/org/chromium/net/DnsOptions.html). |\n| @interface | [DnsOptions.Experimental](../../../../reference/org/chromium/net/DnsOptions.Experimental.html) || An annotation for APIs which are not considered stable yet. |\n| class | [DnsOptions.StaleDnsOptions](../../../../reference/org/chromium/net/DnsOptions.StaleDnsOptions.html) || A class configuring Cronet's stale DNS functionality. |\n\n### Public Method Summary\n\n|------------------------------------------------------------------------------------------------------|-------------------------------------------------------------------------------------------------------------------------------------------------------|\n| static [DnsOptions.Builder](../../../../reference/org/chromium/net/DnsOptions.Builder.html) | [builder](../../../../reference/org/chromium/net/DnsOptions.html#builder())() |\n| Boolean | [getEnableStaleDns](../../../../reference/org/chromium/net/DnsOptions.html#getEnableStaleDns())() |\n| Boolean | [getPersistHostCache](../../../../reference/org/chromium/net/DnsOptions.html#getPersistHostCache())() |\n| Long | [getPersistHostCachePeriodMillis](../../../../reference/org/chromium/net/DnsOptions.html#getPersistHostCachePeriodMillis())() |\n| Boolean | [getPreestablishConnectionsToStaleDnsResults](../../../../reference/org/chromium/net/DnsOptions.html#getPreestablishConnectionsToStaleDnsResults())() |\n| [DnsOptions.StaleDnsOptions](../../../../reference/org/chromium/net/DnsOptions.StaleDnsOptions.html) | [getStaleDnsOptions](../../../../reference/org/chromium/net/DnsOptions.html#getStaleDnsOptions())() |\n| Boolean | [getUseBuiltInDnsResolver](../../../../reference/org/chromium/net/DnsOptions.html#getUseBuiltInDnsResolver())() |\n\n### Inherited Method Summary\n\nFrom class java.lang.Object \n\n|------------------|---------------------------|\n| Object | clone() |\n| boolean | equals(Object arg0) |\n| void | finalize() |\n| final Class\\\u003c?\\\u003e | getClass() |\n| int | hashCode() |\n| final void | notify() |\n| final void | notifyAll() |\n| String | toString() |\n| final void | wait(long arg0, int arg1) |\n| final void | wait(long arg0) |\n| final void | wait() |\n\nPublic Methods\n--------------\n\n#### public static [DnsOptions.Builder](../../../../reference/org/chromium/net/DnsOptions.Builder.html)\n**builder**\n()\n\n\u003cbr /\u003e\n\n#### public Boolean\n**getEnableStaleDns**\n()\n\n\u003cbr /\u003e\n\n#### public Boolean\n**getPersistHostCache**\n()\n\n\u003cbr /\u003e\n\n#### public Long\n**getPersistHostCachePeriodMillis**\n()\n\n\u003cbr /\u003e\n\n#### public Boolean\n**getPreestablishConnectionsToStaleDnsResults**\n()\n\n\u003cbr /\u003e\n\n#### public [DnsOptions.StaleDnsOptions](../../../../reference/org/chromium/net/DnsOptions.StaleDnsOptions.html)\n**getStaleDnsOptions**\n()\n\n\u003cbr /\u003e\n\n#### public Boolean\n**getUseBuiltInDnsResolver**\n()\n\n\u003cbr /\u003e"]]