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
requestNamestringThe request name: printable US-ASCII without spaces or commas, at most 64 characters (RFC 4251 section 6), for example
my-request@example.com.requestDataReadOnlyMemory<byte>The bytes that follow the
want replyflag inSSH_MSG_GLOBAL_REQUEST; empty when the request has none.cancellationTokenCancellationTokenCancels 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
requestNameis not a valid name, orrequestDatais longer than 32,000 bytes.- SshException
The connection failed before the answer came.