public final class DnsPinger extends Handler
We do not use a simple hostname lookup because that could be cached and the API may not differentiate between a time out and a failure lookup (which we really care about).
Handler.Callback
Modifier and Type | Field and Description |
---|---|
static int |
DNS_PING_RESULT
Async response packet for dns pings.
|
static int |
SOCKET_EXCEPTION
An error code for a
DNS_PING_RESULT packet |
static int |
TIMEOUT
An error code for a
DNS_PING_RESULT packet |
Constructor and Description |
---|
DnsPinger(Context context,
String TAG,
Looper looper,
Handler target,
int connectionType) |
Modifier and Type | Method and Description |
---|---|
void |
cancelPings() |
List<InetAddress> |
getDnsList()
Returns a list of DNS addresses, coming from either the link properties of the
specified connection or the default system DNS if the link properties has no dnses.
|
void |
handleMessage(Message msg)
Subclasses must implement this to receive messages.
|
int |
pingDnsAsync(InetAddress dns,
int timeout,
int delay)
Send a ping.
|
dispatchMessage, dump, getLooper, getMessageName, hasCallbacks, hasMessages, hasMessages, obtainMessage, obtainMessage, obtainMessage, obtainMessage, obtainMessage, post, postAtFrontOfQueue, postAtTime, postAtTime, postDelayed, removeCallbacks, removeCallbacks, removeCallbacksAndMessages, removeMessages, removeMessages, runWithScissors, sendEmptyMessage, sendEmptyMessageAtTime, sendEmptyMessageDelayed, sendMessage, sendMessageAtFrontOfQueue, sendMessageAtTime, sendMessageDelayed, toString
public static final int DNS_PING_RESULT
pingDnsAsync(InetAddress, int, int)
arg2 is the delay, or is negative on error.public static final int TIMEOUT
DNS_PING_RESULT
packetpublic static final int SOCKET_EXCEPTION
DNS_PING_RESULT
packetpublic void handleMessage(Message msg)
Handler
handleMessage
in class Handler
public List<InetAddress> getDnsList()
public int pingDnsAsync(InetAddress dns, int timeout, int delay)
DNS_PING_RESULT
to the handler
specified at creation.dns
- address of dns server to pingtimeout
- timeout for pingDNS_PING_RESULT
message.public void cancelPings()