public interface DnsX
A Domain Name System (DNS) service that resolves IP addresses for hostnames.
Most applications will use the default system DNS service. Applications may provide their own implementation to use a different DNS server, to prefer IPv6 addresses over IPv4 addresses, or to force the use of specific known IP addresses for testing or other purposes.
- Since:
- Java 17+
- Author:
- Kimi Liu
- See Also:
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final DnsXA DNS implementation that usesInetAddress.getAllByName(String)to ask the underlying operating system to look up IP addresses. -
Method Summary
Modifier and TypeMethodDescriptionReturns the IP addresses forhostname, in the order they should be attempted.
-
Field Details
-
SYSTEM
A DNS implementation that usesInetAddress.getAllByName(String)to ask the underlying operating system to look up IP addresses. Most customDnsXimplementations should delegate to this instance.
-
-
Method Details
-
lookup
Returns the IP addresses forhostname, in the order they should be attempted. If a connection to an address fails, the HTTP client will retry the connection with the next address until a connection is established, the set of IP addresses is exhausted, or a limit is exceeded.- Parameters:
hostname- the hostname to look up.- Returns:
- a list of IP addresses for the given hostname.
- Throws:
UnknownHostException- if the host is unknown or cannot be resolved.
-