Danisment Gazi Unal
2014-04-19 17:35:49 UTC
Hello!
I'm trying to use com.jcraft.jsch.SocketFactory() to create Socket. I need
to get Socket. I add getSocket() as below:
public class SSHSocketFactory implements com.jcraft.jsch.SocketFactory {
private SSHSocket gSocket = null;
public synchronized Socket createSocket(String host, int port) throws
IOException, UnknownHostException {
gSocket = new SSHSocket(host, port);
return gSocket;
}
.....
public SSHSocket getSocket() {
return gSocket;
}
}
If the same socket factory is called multiple times(including by Jsch
internally too), then It always returns the last socket.
I guess I need a method like createSocket(id,host,port) to get it by
getSocket(id).
How can I safely get Socket created by specic host,port pair ?
thanks in advance...
I'm trying to use com.jcraft.jsch.SocketFactory() to create Socket. I need
to get Socket. I add getSocket() as below:
public class SSHSocketFactory implements com.jcraft.jsch.SocketFactory {
private SSHSocket gSocket = null;
public synchronized Socket createSocket(String host, int port) throws
IOException, UnknownHostException {
gSocket = new SSHSocket(host, port);
return gSocket;
}
.....
public SSHSocket getSocket() {
return gSocket;
}
}
If the same socket factory is called multiple times(including by Jsch
internally too), then It always returns the last socket.
I guess I need a method like createSocket(id,host,port) to get it by
getSocket(id).
How can I safely get Socket created by specic host,port pair ?
thanks in advance...