Module bus.http

Interface DnsX


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

    Fields
    Modifier and Type
    Field
    Description
    static final DnsX
    A DNS implementation that uses InetAddress.getAllByName(String) to ask the underlying operating system to look up IP addresses.
  • Method Summary

    Modifier and Type
    Method
    Description
    lookup(String hostname)
    Returns the IP addresses for hostname, in the order they should be attempted.
  • Field Details

    • SYSTEM

      static final DnsX SYSTEM
      A DNS implementation that uses InetAddress.getAllByName(String) to ask the underlying operating system to look up IP addresses. Most custom DnsX implementations should delegate to this instance.
  • Method Details

    • lookup

      List<InetAddress> lookup(String hostname) throws UnknownHostException
      Returns the IP addresses for hostname, 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.