Table of Contents

Class SshForwardedConnection

Namespace
SshSharp
Assembly
SshSharp.dll

One connection the server forwarded to a handler in this process: a remote forwarding started with ForwardRemotePortAsync(string, int, Func<SshForwardedConnection, CancellationToken, Task>, int, CancellationToken) or ForwardRemoteUnixSocketAsync(string, Func<SshForwardedConnection, CancellationToken, Task>, int, CancellationToken). The handler owns Stream: disposing it closes the connection, and it is disposed for the handler when the handler returns.

public sealed class SshForwardedConnection
Inheritance
SshForwardedConnection
Inherited Members

Remarks

Everything here except Stream is what the server reported when it opened the connection. It describes the connection; it does not authenticate the program at the other end, which anyone who can reach the forwarded port or socket on the server can be.

Properties

BoundAddress

For a forwarded port: the address that was connected on the server, as it reports it. Null for a Unix socket.

BoundPort

For a forwarded port: the port that was connected on the server. Null for a Unix socket.

OriginatorAddress

For a forwarded port: the address of the program that connected, as the server reports it. Null for a Unix socket (the server does not say who connected), or when the server sent none.

OriginatorPort

For a forwarded port: the port of the program that connected, as the server reports it. Null for a Unix socket.

RemoteSocketPath

For a forwarded Unix socket: the socket path that was connected on the server. Null for a forwarded port.

Stream

The connection as a duplex stream (asynchronous only): reads return what the remote program sends, and reads end (return 0) when it has finished sending. Writes go to it. Disposing the stream closes the connection. While nothing reads it, the server is not allowed to send more than the channel's window (ChannelWindowSize, 2 MiB by default), so a handler that stops reading slows the remote program down rather than buffering without limit. ShutdownSendAsync(CancellationToken) ends the writing side only.

Methods

ShutdownSendAsync(CancellationToken)

Ends the writing side of Stream without closing the connection, as Shutdown(SocketShutdown) with Send does: the server is sent end-of-file (SSH_MSG_CHANNEL_EOF), so the remote program reads to the end of what the handler wrote, while the handler can still read what the program sends. For a protocol where the end of a request or a response is the end of the stream.