1 package nl.toolforge.core.util.net; 2 3 import java.io.IOException; 4 import java.net.Socket; 5 6 /*** 7 * @author D.A. Smedes 8 * @version $Id: PingThread.java,v 1.2 2004/11/02 23:57:07 asmedes Exp $ 9 */ 10 public class PingThread extends Thread { 11 12 public final static int DEFAULT_TIMEOUT = 1000; 13 14 private int port = -1; 15 private String host = null; 16 17 private boolean success = false; 18 19 public PingThread(String host, int port) { 20 21 this.port = port; 22 this.host = host; 23 } 24 25 public void run() { 26 27 try { 28 new Socket(host, port); 29 success = true; 30 } catch (IOException e) { 31 success = false; 32 } 33 } 34 35 public boolean pingOk() { 36 return success; 37 } 38 39 }