Class PortFinder

java.lang.Object
org.httpobjects.tck.PortFinder

public class PortFinder extends Object
  • Constructor Details

    • PortFinder

      public PortFinder()
  • Method Details

    • usedPorts

      public static Set<Integer> usedPorts()
    • findFreePort

      public static int findFreePort()
    • allocateFreePort

      public static PortAllocation allocateFreePort(Object context)
      WARNING: there is no guarantee that the port is still free after this has returned ... so, if your code makes that assumption, there is an inherent race condition. Finds a port that was free at the time of allocation. Tries to find ports that the underlying system wants us to use. The availablility of the allocated ports is verified by starting and stopping a server on that port.