Save the date! Android Dev Summit is coming to Sunnyvale, CA on Oct 23-24, 2019.

DnsResolver

public final class DnsResolver
extends Object

java.lang.Object
   ↳ android.net.DnsResolver


Dns resolver class for asynchronous dns querying

Summary

Nested classes

interface DnsResolver.InetAddressAnswerListener

listener for receiving parsed answers 

interface DnsResolver.RawAnswerListener

listener for receiving raw answers 

Constants

int CLASS_IN

int FLAG_EMPTY

int FLAG_NO_CACHE_LOOKUP

int FLAG_NO_CACHE_STORE

int FLAG_NO_RETRY

int TYPE_A

int TYPE_AAAA

Public methods

static DnsResolver getInstance()

Get instance for DnsResolver

void query(Network network, byte[] query, int flags, Handler handler, DnsResolver.RawAnswerListener listener)

Pass in a blob and corresponding setting, get a blob back asynchronously with the entire raw answer.

void query(Network network, String domain, int flags, Handler handler, DnsResolver.InetAddressAnswerListener listener)

Pass in a domain name and corresponding setting, get back a set of InetAddresses asynchronously.

void query(Network network, String domain, int nsClass, int nsType, int flags, Handler handler, DnsResolver.RawAnswerListener listener)

Pass in a domain name and corresponding setting, get a blob back asynchronously with the entire raw answer.

Inherited methods

Constants

CLASS_IN

public static final int CLASS_IN

Constant Value: 1 (0x00000001)

FLAG_EMPTY

public static final int FLAG_EMPTY

Constant Value: 0 (0x00000000)

FLAG_NO_CACHE_LOOKUP

public static final int FLAG_NO_CACHE_LOOKUP

Constant Value: 4 (0x00000004)

FLAG_NO_CACHE_STORE

public static final int FLAG_NO_CACHE_STORE

Constant Value: 2 (0x00000002)

FLAG_NO_RETRY

public static final int FLAG_NO_RETRY

Constant Value: 1 (0x00000001)

TYPE_A

public static final int TYPE_A

Constant Value: 1 (0x00000001)

TYPE_AAAA

public static final int TYPE_AAAA

Constant Value: 28 (0x0000001c)

Public methods

getInstance

public static DnsResolver getInstance ()

Get instance for DnsResolver

Returns
DnsResolver

query

public void query (Network network, 
                byte[] query, 
                int flags, 
                Handler handler, 
                DnsResolver.RawAnswerListener listener)

Pass in a blob and corresponding setting, get a blob back asynchronously with the entire raw answer.

Parameters
network Network: Network specifying which network for querying. null for query on default network. This value may be null.

query byte: blob message This value must never be null.

flags int: flags as a combination of the FLAGS_* constants Value is FLAG_EMPTY, FLAG_NO_RETRY, FLAG_NO_CACHE_STORE, or FLAG_NO_CACHE_LOOKUP

handler Handler: Handler to specify the thread upon which the RawAnswerListener will be invoked. This value must never be null.

listener DnsResolver.RawAnswerListener: a RawAnswerListener which will be called to notify the caller of the result of dns query. This value must never be null.

Throws
ErrnoException

query

public void query (Network network, 
                String domain, 
                int flags, 
                Handler handler, 
                DnsResolver.InetAddressAnswerListener listener)

Pass in a domain name and corresponding setting, get back a set of InetAddresses asynchronously.

Parameters
network Network: Network specifying which network for querying. null for query on default network. This value may be null.

domain String: domain name for querying This value must never be null.

flags int: flags as a combination of the FLAGS_* constants Value is FLAG_EMPTY, FLAG_NO_RETRY, FLAG_NO_CACHE_STORE, or FLAG_NO_CACHE_LOOKUP

handler Handler: Handler to specify the thread upon which the InetAddressAnswerListener will be invoked. This value must never be null.

listener DnsResolver.InetAddressAnswerListener: an InetAddressAnswerListener which will be called to notify the caller of the result of dns query. This value must never be null.

Throws
ErrnoException

query

public void query (Network network, 
                String domain, 
                int nsClass, 
                int nsType, 
                int flags, 
                Handler handler, 
                DnsResolver.RawAnswerListener listener)

Pass in a domain name and corresponding setting, get a blob back asynchronously with the entire raw answer.

Parameters
network Network: Network specifying which network for querying. null for query on default network. This value may be null.

domain String: domain name for querying This value must never be null.

nsClass int: dns class as one of the CLASS_* constants Value is CLASS_IN

nsType int: dns resource record (RR) type as one of the TYPE_* constants Value is TYPE_A, or TYPE_AAAA

flags int: flags as a combination of the FLAGS_* constants Value is FLAG_EMPTY, FLAG_NO_RETRY, FLAG_NO_CACHE_STORE, or FLAG_NO_CACHE_LOOKUP

handler Handler: Handler to specify the thread upon which the RawAnswerListener will be invoked. This value must never be null.

listener DnsResolver.RawAnswerListener: a RawAnswerListener which will be called to notify the caller of the result of dns query. This value must never be null.

Throws
ErrnoException