public interface

Connection

net.schmizz.sshj.connection.Connection
Known Indirect Subclasses

Class Overview

Connection layer of the SSH protocol. Refer to RFC 254.

Summary

Public Methods
abstract void attach(Channel chan)
Attach a Channel to this connection.
abstract void attach(ForwardedChannelOpener opener)
Attach a ForwardedChannelOpener to this connection, which will be delegated opening of any CHANNEL_OPEN packets for which it is responsible.
abstract void forget(ForwardedChannelOpener opener)
Forget an attached ForwardedChannelOpener.
abstract void forget(Channel chan)
Forget an attached Channel.
abstract Channel get(int id)
abstract ForwardedChannelOpener get(String chanType)
abstract int getMaxPacketSize()
abstract int getTimeout()
abstract Transport getTransport()
abstract long getWindowSize()
abstract void join()
Wait for the situation that no channels are attached (e.g., got closed).
abstract int nextID()
abstract Promise<SSHPacketConnectionException> sendGlobalRequest(String name, boolean wantReply, byte[] specifics)
Send an SSH global request.
abstract void sendOpenFailure(int recipient, OpenFailException.Reason reason, String message)
Send a SSH_MSG_OPEN_FAILURE for specified Reason and message.
abstract void setMaxPacketSize(int maxPacketSize)
Set the maximum packet size for the local window this connection recommends to any Channel's that ask for it.
abstract void setTimeout(int timeout)
Set the timeout this connection uses for blocking operations and recommends to any other classes that ask for it.
abstract void setWindowSize(long windowSize)
Set the size for the local window this connection recommends to any Channel's that ask for it.

Public Methods

public abstract void attach (Channel chan)

Attach a Channel to this connection. A channel must be attached to the connection if it is to receive any channel-specific data that is received.

Parameters
chan The channel

public abstract void attach (ForwardedChannelOpener opener)

Attach a ForwardedChannelOpener to this connection, which will be delegated opening of any CHANNEL_OPEN packets for which it is responsible.

Parameters
opener An opener for forwarded channels

public abstract void forget (ForwardedChannelOpener opener)

Forget an attached ForwardedChannelOpener.

Parameters
opener The opener to forget

public abstract void forget (Channel chan)

Forget an attached Channel.

Parameters
chan The channel

public abstract Channel get (int id)

Parameters
id Number of the channel to retrieve
Returns
  • an attached Channel of specified channel number, or null if no such channel was attached

public abstract ForwardedChannelOpener get (String chanType)

Parameters
chanType Channel type
Returns

public abstract int getMaxPacketSize ()

Returns
  • the maximum packet size for the local window this connection recommends to any Channel's that ask for it.

public abstract int getTimeout ()

Returns
  • the timeout in seconds that this connection uses for blocking operations and recommends to any other classes that ask for it.

public abstract Transport getTransport ()

Returns

public abstract long getWindowSize ()

Returns
  • the size for the local window this connection recommends to any Channel's that ask for it.

public abstract void join ()

Wait for the situation that no channels are attached (e.g., got closed).

Throws
InterruptedException if the thread is interrupted

public abstract int nextID ()

Returns
  • an available ID a Channel can rightfully claim.

public abstract Promise<SSHPacketConnectionException> sendGlobalRequest (String name, boolean wantReply, byte[] specifics)

Send an SSH global request.

Parameters
name Request name
wantReply Whether a reply is requested
specifics SSHPacket containing fields specific to the request
Returns
  • a Promise for the reply data (in case wantReply is true) which allows waiting on the reply, or null if a reply is not requested.
Throws
TransportException if there is an error sending the request

public abstract void sendOpenFailure (int recipient, OpenFailException.Reason reason, String message)

Send a SSH_MSG_OPEN_FAILURE for specified Reason and message.

Parameters
recipient Number of the recipient channel
reason A reason for the failure
message An explanatory message
Throws
TransportException if there is a transport-layer error

public abstract void setMaxPacketSize (int maxPacketSize)

Set the maximum packet size for the local window this connection recommends to any Channel's that ask for it.

Parameters
maxPacketSize Maximum packet size in bytes

public abstract void setTimeout (int timeout)

Set the timeout this connection uses for blocking operations and recommends to any other classes that ask for it.

Parameters
timeout Timeout in seconds

public abstract void setWindowSize (long windowSize)

Set the size for the local window this connection recommends to any Channel's that ask for it.

Parameters
windowSize Window size in bytes