Package io.micronaut.core.io.socket
Class SocketUtils
java.lang.Object
io.micronaut.core.io.socket.SocketUtils
Utility methods for dealing with sockets.
- Since:
- 1.0
- Author:
- Graeme Rocher
-
Field Summary
Modifier and TypeFieldDescriptionstatic final String
Constant for localhost.static final int
The maximum port number.static final int
The minimum port number. -
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionstatic int
Finds an available TCP port.static int
findAvailableTcpPort
(int minPortRange, int maxPortRange) Finds an available TCP port.static boolean
isTcpPortAvailable
(int currentPort) Check whether the given TCP port is available.
-
Field Details
-
LOCALHOST
Constant for localhost.- See Also:
-
MIN_PORT_RANGE
public static final int MIN_PORT_RANGEThe minimum port number.- See Also:
-
MAX_PORT_RANGE
public static final int MAX_PORT_RANGEThe maximum port number.- See Also:
-
-
Constructor Details
-
SocketUtils
public SocketUtils()
-
-
Method Details
-
findAvailableTcpPort
public static int findAvailableTcpPort()Finds an available TCP port.- Returns:
- The available port
-
findAvailableTcpPort
public static int findAvailableTcpPort(int minPortRange, int maxPortRange) Finds an available TCP port.- Parameters:
minPortRange
- The minimum port rangemaxPortRange
- The maximum port range- Returns:
- The available port
-
isTcpPortAvailable
public static boolean isTcpPortAvailable(int currentPort) Check whether the given TCP port is available.- Parameters:
currentPort
- The port- Returns:
- True if it is
-