Package se.datadosen.net
Class NetUtil
java.lang.Object
se.datadosen.net.NetUtil
-
Method Summary
Modifier and TypeMethodDescriptionstatic int
Attempt to get a reasonably free server portstatic int
getFreeServerPort
(int suggestedPort) static String
Getting the host address on the LAN is tricky.static boolean
-
Method Details
-
isLocal
-
getLocalHostAddress
Getting the host address on the LAN is tricky. InetAddress.getLocalHost().getHostAddress() often delivers 127.0.0.1 Using hack from https://www.baeldung.com/java-get-ip-address Supposed to not work on Mac (April 2022), but I've tested this fine on Mac, Windows and Linux- Returns:
- Local host address
-
getFreeServerPort
public static int getFreeServerPort(int suggestedPort) - Parameters:
suggestedPort
-- Returns:
- First free server port starting from suggestedPort
- Since:
- 31
-
getFreeServerPort
public static int getFreeServerPort()Attempt to get a reasonably free server port- Returns:
-