Class FreePort
java.lang.Object
com.shaft.commandline.session.FreePort
Allocates an ephemeral loopback TCP port for the daemon to bind.
-
Method Summary
Modifier and TypeMethodDescriptionstatic intfind()Binds a transientServerSocketto port 0 on127.0.0.1, reads back the port the OS assigned, and closes the socket so the daemon can bind it.
-
Method Details
-
find
public static int find()Binds a transientServerSocketto port 0 on127.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
-