Package net.schmizz.sshj.connection
Interface Connection
- All Known Implementing Classes:
ConnectionImpl
public interface Connection
Connection layer of the SSH protocol. Refer to RFC 254.
-
Method Summary
Modifier and TypeMethodDescriptionvoid
Attach aChannel
to this connection.void
attach
(ForwardedChannelOpener opener) Attach aForwardedChannelOpener
to this connection, which will be delegated opening of anyCHANNEL_OPEN
packetsfor which it is responsible
.void
Forget an attachedChannel
.void
forget
(ForwardedChannelOpener opener) Forget an attachedForwardedChannelOpener
.get
(int id) int
int
long
void
join()
Wait for the situation that no channels are attached (e.g., got closed).int
nextID()
sendGlobalRequest
(String name, boolean wantReply, byte[] specifics) Send an SSH global request.void
sendOpenFailure
(int recipient, OpenFailException.Reason reason, String message) Send aSSH_MSG_OPEN_FAILURE
for specifiedReason
andmessage
.void
setMaxPacketSize
(int maxPacketSize) Set the maximum packet size for the local window this connection recommends to anyChannel
's that ask for it.void
setTimeoutMs
(int timeout) void
setWindowSize
(long windowSize) Set the size for the local window this connection recommends to anyChannel
's that ask for it.
-
Method Details
-
attach
Attach aChannel
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
-
attach
Attach aForwardedChannelOpener
to this connection, which will be delegated opening of anyCHANNEL_OPEN
packetsfor which it is responsible
.- Parameters:
opener
- an opener for forwarded channels
-
forget
Forget an attachedChannel
.- Parameters:
chan
- the channel
-
forget
Forget an attachedForwardedChannelOpener
.- Parameters:
opener
- the opener to forget
-
get
- Parameters:
id
- number of the channel to retrieve- Returns:
- an attached
Channel
of specified channel number, ornull
if no such channel was attached
-
join
Wait for the situation that no channels are attached (e.g., got closed).- Throws:
InterruptedException
- if the thread is interrupted
-
get
- Parameters:
chanType
- channel type- Returns:
- an attached
ForwardedChannelOpener
of specified channel-type, ornull
if no such channel was attached
-
nextID
int nextID()- Returns:
- an available ID a
Channel
can rightfully claim.
-
sendGlobalRequest
Promise<SSHPacket,ConnectionException> sendGlobalRequest(String name, boolean wantReply, byte[] specifics) throws TransportException Send an SSH global request.- Parameters:
name
- request namewantReply
- whether a reply is requestedspecifics
-SSHPacket
containing fields specific to the request- Returns:
- a
Promise
for the reply data (in casewantReply
is true) which allows waiting on the reply, ornull
if a reply is not requested. - Throws:
TransportException
- if there is an error sending the request
-
sendOpenFailure
void sendOpenFailure(int recipient, OpenFailException.Reason reason, String message) throws TransportException Send aSSH_MSG_OPEN_FAILURE
for specifiedReason
andmessage
.- Parameters:
recipient
- number of the recipient channelreason
- a reason for the failuremessage
- an explanatory message- Throws:
TransportException
- if there is a transport-layer error
-
getMaxPacketSize
int getMaxPacketSize()- Returns:
- the maximum packet size for the local window this connection recommends to any
Channel
's that ask for it.
-
setMaxPacketSize
void setMaxPacketSize(int maxPacketSize) Set the maximum packet size for the local window this connection recommends to anyChannel
's that ask for it.- Parameters:
maxPacketSize
- maximum packet size in bytes
-
getWindowSize
long getWindowSize()- Returns:
- the size for the local window this connection recommends to any
Channel
's that ask for it.
-
setWindowSize
void setWindowSize(long windowSize) Set the size for the local window this connection recommends to anyChannel
's that ask for it.- Parameters:
windowSize
- window size in bytes
-
getTransport
Transport getTransport()- Returns:
- the associated
Transport
.
-
getTimeoutMs
int getTimeoutMs() -
setTimeoutMs
void setTimeoutMs(int timeout) Set thetimeout
this connection uses for blocking operations and recommends to anyother
classes
that ask for it.- Parameters:
timeout
- timeout in milliseconds
-
getKeepAlive
KeepAlive getKeepAlive()- Returns:
- The configured
KeepAlive
mechanism.
-