Package org.dawb.common.util.net
Class NetUtils
java.lang.Object
org.dawb.common.util.net.NetUtils
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic intAttempts to get a free port by asking a ServerSocket to find one, and then closing that socket and returning the port it used.static intgetFreePort(int startPort) Attempts to get a free port starting at the passed in port and working up.static booleanisPortFree(int port) Checks if a port is free.
-
Constructor Details
-
NetUtils
public NetUtils()
-
-
Method Details
-
getFreePort
public static int getFreePort(int startPort) Attempts to get a free port starting at the passed in port and working up.- Parameters:
startPort-- Returns:
-
getFreePort
Attempts to get a free port by asking a ServerSocket to find one, and then closing that socket and returning the port it used.- Returns:
- Throws:
IOException
-
isPortFree
public static boolean isPortFree(int port) Checks if a port is free.- Parameters:
port-- Returns:
-