Package io.micronaut.core.io.socket
Class SocketUtils
- java.lang.Object
-
- io.micronaut.core.io.socket.SocketUtils
-
public class SocketUtils extends java.lang.Object
Utility methods for dealing with sockets.- Since:
- 1.0
-
-
Field Summary
Fields Modifier and Type Field Description static java.lang.String
LOCALHOST
Constant for localhost.static int
MAX_PORT_RANGE
The maximum port number.static int
MIN_PORT_RANGE
The minimum port number.
-
Constructor Summary
Constructors Constructor Description SocketUtils()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static int
findAvailableTcpPort()
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 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
-
-