We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
if you have a predefined port number, you can create a local port forwarder like this:
LocalPortForwarder forwarder = connection.createLocalPortForwarder(localPort, hostname, port);
the problem is that the port can be taken. you can try getting an unused port by doing something like this:
static int findAvailablePort() throws IOException { try (ServerSocket socket = new ServerSocket(0)) { return socket.getLocalPort(); } }
but it can lead to a race condition.
the solution would be to add a new api such as LocalPortForwarder.getLocalPort() or allow users to create ServerSockets themselves, as in
LocalPortForwarder.getLocalPort()
ServerSocket
ServerSocket serverSocket = new ServerSocket(0); connection.createLocalPortForwarder(serverSocket, hostname, port); int localPort = serverSocket.getLocalPort();
The text was updated successfully, but these errors were encountered:
Successfully merging a pull request may close this issue.
if you have a predefined port number, you can create a local port forwarder like this:
the problem is that the port can be taken. you can try getting an unused port by doing something like this:
but it can lead to a race condition.
the solution would be to add a new api such as
LocalPortForwarder.getLocalPort()
or allow users to createServerSocket
s themselves, as inThe text was updated successfully, but these errors were encountered: