import java.io.IOException;
import java.net.InetAddress;
import java.net.InetSocketAddress;
import java.nio.channels.SelectionKey;
import java.nio.channels.Selector;
import java.nio.channels.SocketChannel;
import java.util.Iterator;
import java.util.LinkedList;
import java.util.regex.Pattern;
public class Ping {
// The default daytime port
static int DAYTIME_PORT = 13;
// The port we'll actually use
static int port = DAYTIME_PORT;
private String host;
public String getHost() {
return host;
}
public void setHost(String host) {
this.host = host;
}
public void setPort(int port){
this.port = port;
}
// private String
// Representation of a ping target
//
static class Target {
InetSocketAddress address;
SocketChannel channel;
Exception failure;
long connectStart;
long connectFinish = 0;
boolean shown = false;
boolean pingResult = false;
Target(String host) {
try {
address = new InetSocketAddress(InetAddress.getByName(host), port);
} catch