Package net.schmizz.sshj.connection
Interface Connection
-
- All Known Implementing Classes:
ConnectionImpl
public interface ConnectionConnection layer of the SSH protocol. Refer to RFC 254.
-
-
Method Summary
Modifier and Type Method Description voidattach(Channel chan)Attach aChannelto this connection.voidattach(ForwardedChannelOpener opener)Attach aForwardedChannelOpenerto this connection, which will be delegated opening of anyCHANNEL_OPENpacketsfor which it is responsible.voidforget(Channel chan)Forget an attachedChannel.voidforget(ForwardedChannelOpener opener)Forget an attachedForwardedChannelOpener.Channelget(int id)ForwardedChannelOpenerget(java.lang.String chanType)KeepAlivegetKeepAlive()intgetMaxPacketSize()intgetTimeoutMs()TransportgetTransport()longgetWindowSize()voidjoin()Wait for the situation that no channels are attached (e.g., got closed).intnextID()Promise<SSHPacket,ConnectionException>sendGlobalRequest(java.lang.String name, boolean wantReply, byte[] specifics)Send an SSH global request.voidsendOpenFailure(int recipient, OpenFailException.Reason reason, java.lang.String message)Send aSSH_MSG_OPEN_FAILUREfor specifiedReasonandmessage.voidsetMaxPacketSize(int maxPacketSize)Set the maximum packet size for the local window this connection recommends to anyChannel's that ask for it.voidsetTimeoutMs(int timeout)voidsetWindowSize(long windowSize)Set the size for the local window this connection recommends to anyChannel's that ask for it.
-
-
-
Method Detail
-
attach
void attach(Channel chan)
Attach aChannelto 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
void attach(ForwardedChannelOpener opener)
Attach aForwardedChannelOpenerto this connection, which will be delegated opening of anyCHANNEL_OPENpacketsfor which it is responsible.- Parameters:
opener- an opener for forwarded channels
-
forget
void forget(ForwardedChannelOpener opener)
Forget an attachedForwardedChannelOpener.- Parameters:
opener- the opener to forget
-
get
Channel get(int id)
- Parameters:
id- number of the channel to retrieve- Returns:
- an attached
Channelof specified channel number, ornullif no such channel was attached
-
join
void join() throws java.lang.InterruptedException
Wait for the situation that no channels are attached (e.g., got closed).- Throws:
java.lang.InterruptedException- if the thread is interrupted
-
get
ForwardedChannelOpener get(java.lang.String chanType)
- Parameters:
chanType- channel type- Returns:
- an attached
ForwardedChannelOpenerof specified channel-type, ornullif no such channel was attached
-
nextID
int nextID()
- Returns:
- an available ID a
Channelcan rightfully claim.
-
sendGlobalRequest
Promise<SSHPacket,ConnectionException> sendGlobalRequest(java.lang.String name, boolean wantReply, byte[] specifics) throws TransportException
Send an SSH global request.- Parameters:
name- request namewantReply- whether a reply is requestedspecifics-SSHPacketcontaining fields specific to the request- Returns:
- a
Promisefor the reply data (in casewantReplyis true) which allows waiting on the reply, ornullif a reply is not requested. - Throws:
TransportException- if there is an error sending the request
-
sendOpenFailure
void sendOpenFailure(int recipient, OpenFailException.Reason reason, java.lang.String message) throws TransportExceptionSend aSSH_MSG_OPEN_FAILUREfor specifiedReasonandmessage.- 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
-
getTimeoutMs
int getTimeoutMs()
-
setTimeoutMs
void setTimeoutMs(int timeout)
Set thetimeoutthis connection uses for blocking operations and recommends to anyotherclassesthat ask for it.- Parameters:
timeout- timeout in milliseconds
-
-