Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- private static boolean testConn(String host, int port)
- {
- // Java Socket default timeout value: 60000 milliseconds
- Socket socket = null;
- try {
- socket = new Socket(host, port) ;
- return true;
- } catch(ConnectException e){
- System.out.println("testConn ConnectException, host:"+host+", port:"+port);
- return false;
- } catch (IOException e) {
- System.out.println("testConn IOException, host:"+host+", port:"+port);
- return false;
- }catch (Exception e) {
- System.out.println("testConn Exception, host:"+host+", port:"+port);
- return false;
- }finally{
- try {
- socket.close();
- } catch (IOException e) {
- System.out.println("testConn socket close fail");
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment