<PackageReference Include="SSH.NET" Version="2024.0.0" />

Channel

abstract class Channel : IChannel, IDisposable
Represents base class for SSH channel implementations.
public abstract ChannelTypes ChannelType { get; }

Gets the type of the channel.

protected IConnectionInfo ConnectionInfo { get; }

Gets the connection info.

protected bool IsConnected { get; }

Gets a value indicating whether the session is connected.

public bool IsOpen { get; protected set; }

Gets or sets a value indicating whether this channel is open.

public uint LocalChannelNumber { get; }

Gets the local channel number.

public uint LocalPacketSize { get; }

Gets the maximum size of a data packet that we can receive using the channel.

public uint LocalWindowSize { get; }

Gets the size of the local window.

public uint RemoteChannelNumber { get; }

Gets the remote channel number.

public uint RemotePacketSize { get; }

Gets the maximum size of a data packet that we can send using the channel.

public uint RemoteWindowSize { get; }

Gets the window size of the remote server.

protected ISession Session { get; }

Gets the session.

protected SemaphoreSlim SessionSemaphore { get; }

Gets the session semaphore to control number of session channels.

Occurs when ChannelCloseMessage is received.

Occurs when ChannelDataMessage is received.

Occurs when ChannelEofMessage is received.

Occurs when an exception is thrown when processing channel messages.

Occurs when ChannelExtendedDataMessage is received.

Occurs when ChannelFailureMessage is received.

Occurs when ChannelRequestMessage is received.

Occurs when ChannelSuccessMessage is received.

protected Channel(ISession session, uint localChannelNumber, uint localWindowSize, uint localPacketSize)

Initializes a new instance of the Channel class.

protected virtual void Close()

Closes the channel, waiting for the SSH_MSG_CHANNEL_CLOSE message to be received from the server.

public void Dispose()

Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.

protected virtual void Dispose(bool disposing)

Releases unmanaged and - optionally - managed resources.

protected void InitializeRemoteInfo(uint remoteChannelNumber, uint remoteWindowSize, uint remotePacketSize)

Initializes the information on the remote channel.

protected void OnChannelException(Exception ex)

Called when an Exception occurs while processing a channel message.

protected virtual void OnClose()

Called when channel is closed by the server.

protected virtual void OnData(byte[] data)

Called when channel data is received.

protected virtual void OnDisconnected()

protected virtual void OnEof()

Called when channel has no more data to receive.

protected virtual void OnErrorOccured(Exception exp)

protected virtual void OnExtendedData(byte[] data, uint dataTypeCode)

Called when channel extended data is received.

protected virtual void OnFailure()

Called when channel request failed.

protected virtual void OnRequest(RequestInfo info)

Called when channel request received.

protected virtual void OnSuccess()

Called when channel request was successful.

protected virtual void OnWindowAdjust(uint bytesToAdd)

Called when channel window need to be adjust.

public void SendData(byte[] data)

Sends a SSH_MSG_CHANNEL_DATA message with the specified payload.

public void SendData(byte[] data, int offset, int size)

Sends a SSH_MSG_CHANNEL_DATA message with the specified payload.

public void SendEof()

Sends a SSH_MSG_CHANNEL_EOF message to the remote server.

protected void SendMessage(Message message)

Sends SSH message to the server.

protected void WaitOnHandle(WaitHandle waitHandle)

Waits for the handle to be signaled or for an error to occurs.