code: private static int getOpenPort() throws IOException {
          Log.info(c, "getOpenPort", "Entry.");
          ServerSocket s = new ServerSocket(0);
          Log.info(c, "getOpenPort", "Got socket.");
          int port = s.getLocalPort();
          Log.info(c, "getOpenPort", "Got port " + s);
          s.close();
          Log.info(c, "getOpenPort", "Close socket");
          return port;
      }
docs: Get a free port.
  
  @return The free port.
  @throws IOException If a free port could not be found.