Table of Contents

Method SendGlobalRequestAsync

Namespace
SshSharp
Assembly
SshSharp.dll

SendGlobalRequestAsync(string, ReadOnlyMemory<byte>, CancellationToken)

Sends a global request (RFC 4254 section 4), for a server's own or vendor requests that SshSharp has no API for, and waits for the answer. requestData is sent as is after the request name and want reply flag, so encode it as the request defines. A server answers a request it does not know with a failure, which is returned, not thrown.

public Task<SshGlobalRequestResult> SendGlobalRequestAsync(string requestName, ReadOnlyMemory<byte> requestData = default, CancellationToken cancellationToken = default)

Parameters

requestName string

The request name: printable US-ASCII without spaces or commas, at most 64 characters (RFC 4251 section 6), for example my-request@example.com.

requestData ReadOnlyMemory<byte>

The bytes that follow the want reply flag in SSH_MSG_GLOBAL_REQUEST; empty when the request has none.

cancellationToken CancellationToken

Cancels waiting for the answer. The request has gone out by then, and its late answer is dropped.

Returns

Task<SshGlobalRequestResult>

Whether the server granted the request, and the data of its answer.

Exceptions

ArgumentException

requestName is not a valid name, or requestData is longer than 32,000 bytes.

SshException

The connection failed before the answer came.