Class NetUtil

java.lang.Object
se.datadosen.net.NetUtil

public class NetUtil extends Object
  • Method Details

    • isLocal

      public static boolean isLocal(URL url)
    • getLocalHostAddress

      public static String 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: