Docjar: A Java Source and Docuemnt Enginecom.*    java.*    javax.*    org.*    all    new    plug-in

Quick Search    Search Deep

pspdash
Class Ping  view Ping download Ping.java

java.lang.Object
  extended bypspdash.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.


Field Summary
static int CANNOT_CONNECT
           
private static int CONNECTING_TO_HOST
           
static int HOST_NOT_FOUND
           
private  java.lang.String hostname
           
private static int LOOKING_FOR_HOST
           
private  int port
           
private  int status
           
static int SUCCESS
           
 
Constructor Summary
private Ping(java.lang.String hostname, int port)
           
 
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
 

Field Detail

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
Constructor Detail

Ping

private Ping(java.lang.String hostname,
             int port)
Method Detail

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)