Package io.micronaut.core.io.socket
Class SocketUtils
- java.lang.Object
-
- io.micronaut.core.io.socket.SocketUtils
-
public class SocketUtils extends java.lang.ObjectUtility methods for dealing with sockets.- Since:
- 1.0
-
-
Field Summary
Fields Modifier and Type Field Description static java.lang.StringLOCALHOSTConstant for localhost.static intMAX_PORT_RANGEThe maximum port number.static intMIN_PORT_RANGEThe minimum port number.
-
Constructor Summary
Constructors Constructor Description SocketUtils()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static intfindAvailableTcpPort()Finds an available TCP port.static intfindAvailableTcpPort(int minPortRange, int maxPortRange)Finds an available TCP port.static booleanisTcpPortAvailable(int currentPort)Check whether the given TCP port is available.
-
-
-
Field Detail
-
LOCALHOST
public static final java.lang.String LOCALHOST
Constant for localhost.- See Also:
- Constant Field Values
-
MIN_PORT_RANGE
public static final int MIN_PORT_RANGE
The minimum port number.- See Also:
- Constant Field Values
-
MAX_PORT_RANGE
public static final int MAX_PORT_RANGE
The maximum port number.- See Also:
- Constant Field Values
-
-
Method Detail
-
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
-
-