Package org.kiwiproject.net
Class LocalPortChecker
- java.lang.Object
-
- org.kiwiproject.net.LocalPortChecker
-
public class LocalPortChecker extends Object
Utility to check port availability.
-
-
Field Summary
Fields Modifier and Type Field Description static intMAX_PORT
-
Constructor Summary
Constructors Constructor Description LocalPortChecker()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description OptionalIntfindFirstOpenPortAbove(int port)Find the first open port above the given port (i.e.booleanisPortAvailable(int port)Check port availability.
-
-
-
Field Detail
-
MAX_PORT
public static final int MAX_PORT
- See Also:
- Constant Field Values
-
-
Method Detail
-
isPortAvailable
public boolean isPortAvailable(int port)
Check port availability.- Parameters:
port- the port to check on the local machine- Returns:
trueif the port is available;falseotherwise
-
findFirstOpenPortAbove
public OptionalInt findFirstOpenPortAbove(int port)
Find the first open port above the given port (i.e. if port is 1024 then the first port to be checked will be 1025). If none are found return an emptyOptionalInt- Parameters:
port- the port to check above- Returns:
- an optional containing the first open port, or an empty optional
-
-