SSHTools Knowledgebase
Information and FAQs about SSHTools products
  
Search  
   
Browse by Category
SSHTools Knowledgebase .: J2SSH Maverick .: How do I configure socket timeouts?

How do I configure socket timeouts?

When connecting to an SSH server the SocketTransport class is typically used to establish the socket. This class is simply an extended Socket thatimplements the SshTransport interface. If you require a socket timeout you can simply set the timeout on the SocketTransport instance before passing it into the Maverick API.

SocketTransport transport = new SocketTransport(hostname, port);
transport.setSoTimeout(60000);

SshClient ssh = con.connect(transport, username);

Once a timeout has been set you should amend your code to examine any SshException thrown by the API. If a timeout is detected by the API an SshException is thrown with the SOCKET_TIMEOUT reason code.


How helpful was this article to you?

User Comments

Add Comment
No comments have been posted.


powered by Lore
© 2008 SSHTools Ltd. All Rights Reserved