It is already possible to let the OS allocate an ephemeral port when starting the SOCKS proxy server with port = 0.
This very simple PR allows to retrieve the allocated port after the server is started by introducing a getter :
AnonymousSocks5Server s = new AnonymousSocks5ServerImpl(new AuthenticatingSocks5Bridge(socksProxyConfig), 0);
// Get SOCKS server port
int port = s.getLocalPort();
It is already possible to let the OS allocate an ephemeral port when starting the SOCKS proxy server with port = 0.
This very simple PR allows to retrieve the allocated port after the server is started by introducing a getter :
So it can be used in other projects.