Class NetUtils

java.lang.Object
org.dawb.common.util.net.NetUtils

public class NetUtils extends Object
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    static int
    Attempts to get a free port by asking a ServerSocket to find one, and then closing that socket and returning the port it used.
    static int
    getFreePort(int startPort)
    Attempts to get a free port starting at the passed in port and working up.
    static boolean
    isPortFree(int port)
    Checks if a port is free.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • 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

      public static int getFreePort() throws IOException
      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: