mirror of
https://github.com/hierynomus/sshj.git
synced 2025-12-07 15:50:57 +03:00
connected sockets can be passed to the library (#925)
* connected sockets can be passed to the library fixes hierynomus/sshj#924 Signed-off-by: Martin Volf <vlci.doupe@gmail.com> * removed pointless socket check; test coverage improved Signed-off-by: Martin Volf <vlci.doupe@gmail.com> * better test coverage Signed-off-by: Martin Volf <vlci.doupe@gmail.com> --------- Signed-off-by: Martin Volf <vlci.doupe@gmail.com>
This commit is contained in:
@@ -65,7 +65,9 @@ public abstract class SocketClient {
|
||||
this.hostname = hostname;
|
||||
this.port = port;
|
||||
socket = socketFactory.createSocket();
|
||||
socket.connect(makeInetSocketAddress(hostname, port), connectTimeout);
|
||||
if (! socket.isConnected()) {
|
||||
socket.connect(makeInetSocketAddress(hostname, port), connectTimeout);
|
||||
}
|
||||
onConnect();
|
||||
}
|
||||
}
|
||||
@@ -104,7 +106,9 @@ public abstract class SocketClient {
|
||||
public void connect(InetAddress host, int port) throws IOException {
|
||||
this.port = port;
|
||||
socket = socketFactory.createSocket();
|
||||
socket.connect(new InetSocketAddress(host, port), connectTimeout);
|
||||
if (! socket.isConnected()) {
|
||||
socket.connect(new InetSocketAddress(host, port), connectTimeout);
|
||||
}
|
||||
onConnect();
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user