Пример #1
0
  /*
   *  Example usage of an 'outbound' socket client.  Of course an application developer would need to
   *  create their own implementation of a handler and pipeline factory, and invoke the SocketClient.
   *
   */
  @Test
  public void run_client() throws InterruptedException {
    log.info("Test starting ...");

    SocketClient client = new SocketClient(8084, new SimpleHangupPipelineFactory());

    client.start();

    Thread.sleep(45000);

    client.stop();

    log.info("Test ended");
  }
Пример #2
0
 /**
  * On connection establishment, also initializes the SSH transport via {@link Transport#init} and
  * {@link #doKex()}.
  */
 @Override
 protected void onConnect() throws IOException {
   super.onConnect();
   trans.init(getRemoteHostname(), getRemotePort(), getInputStream(), getOutputStream());
   doKex();
 }
Пример #3
0
 @Override
 public void close() throws IOException {
   client.close();
 }
Пример #4
0
 /**
  * Disconnects from the connected SSH server. {@code SSHClient} objects are not reusable therefore
  * it is incorrect to attempt connection after this method has been called.
  *
  * <p>This method should be called from a {@code finally} construct after connection is
  * established; so that proper cleanup is done and the thread spawned by the transport layer for
  * dealing with incoming packets is stopped.
  */
 @Override
 public void disconnect() throws IOException {
   trans.disconnect();
   super.disconnect();
   assert !isConnected();
 }