检查IP和端口在超时时间内是否可以连接
/** * 检查IP和端口是否可以连接 * @param ip * @param port * @return */ private static boolean testConnect(String ip,int port) { Boolean isConnect = false; Socket connect = new Socket(); try { InetSocketAddress inetSocketAddress = new InetSocketAddress(ip, port); connect.connect(inetSocketAddress, 1500); isConnect = connect.isConnected(); } catch (IOException e) { }finally { if (connect != null) { try { connect.close(); } catch (IOException e) { } } } return isConnect; }