java.lang.Object
pspdash.Ping
- All Implemented Interfaces:
- java.lang.Runnable
- public class Ping
- extends java.lang.Object
- implements java.lang.Runnable
Poor man's ping.
We can't really do ping without resorting to java native methods,
since java doesn't contain support for the ICMP protocol.
Although there are some "java ping" classes out there, they all
use UDP to connect to port 7 on the remote computer (the echo
port). Windows computers don't listen on the echo port, so this
won't work reliably.
Method Summary |
static int |
ping(java.lang.String hostname,
int port,
long maxWait)
|
void |
run()
This method will be called by whoever wishes to run your class
implementing Runnable. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
HOST_NOT_FOUND
public static final int HOST_NOT_FOUND
- See Also:
- Constant Field Values
LOOKING_FOR_HOST
private static final int LOOKING_FOR_HOST
- See Also:
- Constant Field Values
CANNOT_CONNECT
public static final int CANNOT_CONNECT
- See Also:
- Constant Field Values
CONNECTING_TO_HOST
private static final int CONNECTING_TO_HOST
- See Also:
- Constant Field Values
SUCCESS
public static final int SUCCESS
- See Also:
- Constant Field Values
hostname
private java.lang.String hostname
port
private int port
status
private int status
Ping
private Ping(java.lang.String hostname,
int port)
run
public void run()
- Description copied from interface:
java.lang.Runnable
- This method will be called by whoever wishes to run your class
implementing Runnable. Note that there are no restrictions on what
you are allowed to do in the run method, except that you cannot
throw a checked exception.
- Specified by:
run
in interface java.lang.Runnable
ping
public static int ping(java.lang.String hostname,
int port,
long maxWait)