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
27
28
package org.jeecg.modules.dnc.utils;
 
import java.io.IOException;
import java.net.InetSocketAddress;
import java.net.Socket;
 
/**
 * @author clown
 * * @date 2023/12/1
 */
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;
        }
    }
}