lyh
2026-02-25 b1fc02cdbfb6d031973897f26839789a3f880b84
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
package com.lxzn.framework.utils;
 
import java.io.IOException;
import java.net.InetSocketAddress;
import java.net.Socket;
 
public class TelnetUtil {
 
 
    public static boolean telnetPort(String hostname,int port ,int timeOut) {
        Socket socket = new Socket();
        boolean isBool = false;
        try {
            socket.connect(new InetSocketAddress(hostname,port),timeOut);
            isBool = socket.isConnected();
            return isBool;
        } catch (IOException e) {
            try {
                socket.close();
            } catch (IOException e1) {
                e1.printStackTrace();
            }
            return isBool;
        }
    }
}