public class Ports extends Object
Modifier and Type | Method and Description |
---|---|
static List<Integer> |
getClosePorts(String host,
int[] ports)
获取未开启的端口
|
static List<Integer> |
getClosePorts(String host,
int start,
int end)
获取未开启的端口
|
static int |
getFreePort()
获取一个空闲的本地端口
|
static int |
getFreePort(int[] ports)
获取一个空闲的本地端口
|
static int |
getFreePort(int start,
int end)
获取一个空闲的本地端口
|
static List<Integer> |
getFreePorts(int[] ports)
获取空闲的本地端口
|
static List<Integer> |
getFreePorts(int start,
int end)
获取空闲的本地端口
|
static List<Integer> |
getOpenPorts(String host,
int[] ports)
获取已开启的端口
|
static List<Integer> |
getOpenPorts(String host,
int start,
int end)
获取已开启的端口
|
static int |
getTimeout()
获取当前建立连接超时时间
|
static List<Integer> |
getUsedPorts(int[] ports)
获取占用的本地端口
|
static List<Integer> |
getUsedPorts(int start,
int end)
获取占用的本地端口
|
static boolean |
isClose(String host,
int port)
判断端口是否关闭
|
static boolean |
isFree(int port)
判断端口是否空闲
|
static boolean |
isOpen(String host,
int port)
判断端口是否开启
|
static boolean |
isUsed(int port)
判断端口是否占用
|
static void |
setTimeout(int timeout)
设置建立连接超时时间
|
public static int getFreePort()
public static int getFreePort(int[] ports)
ports
- portspublic static int getFreePort(int start, int end)
start
- 端口开始end
- 端口结束public static List<Integer> getFreePorts(int[] ports)
ports
- portspublic static List<Integer> getFreePorts(int start, int end)
start
- 端口开始end
- 端口结束public static List<Integer> getUsedPorts(int[] ports)
ports
- portspublic static List<Integer> getUsedPorts(int start, int end)
start
- 端口开始end
- 端口结束public static boolean isFree(int port)
port
- 端口public static boolean isUsed(int port)
port
- 端口public static List<Integer> getOpenPorts(String host, int[] ports)
host
- 主机ports
- 端口public static List<Integer> getOpenPorts(String host, int start, int end)
host
- 主机start
- 端口开始end
- 端口结束public static List<Integer> getClosePorts(String host, int[] ports)
host
- 主机ports
- 端口public static List<Integer> getClosePorts(String host, int start, int end)
host
- 主机start
- 端口开始end
- 端口结束public static boolean isOpen(String host, int port)
host
- 主机port
- 端口public static boolean isClose(String host, int port)
host
- 主机port
- 端口public static int getTimeout()
public static void setTimeout(int timeout)
timeout
- 超时时间msCopyright © 2024. All rights reserved.