Class FreePort

java.lang.Object
com.shaft.commandline.session.FreePort

public final class FreePort extends Object
Allocates an ephemeral loopback TCP port for the daemon to bind.
  • Method Details

    • find

      public static int find()
      Binds a transient ServerSocket to port 0 on 127.0.0.1, reads back the port the OS assigned, and closes the socket so the daemon can bind it.
      Returns:
      a currently-free TCP port on the loopback interface