2012-04-06 133 views

回答

1

檢查阿帕奇百科全書網庫

https://commons.apache.org/net/

從他們example

public static final void timeTCP(String host) throws IOException 
{ 
    TimeTCPClient client = new TimeTCPClient(); 
    try { 
      // We want to timeout if a response takes longer than 60 seconds 
      client.setDefaultTimeout(60000); 
      client.connect(host); 
      System.out.println(client.getDate()); 
    } finally { 
      client.disconnect(); 
    } 
}