Table of Contents

Class SshDataStream

Namespace
Renci.SshNet.Common
Assembly
Renci.SshNet.dll

Specialized MemoryStream for reading and writing data SSH data.

public class SshDataStream : MemoryStream, IDisposable, IAsyncDisposable
Inheritance
SshDataStream
Implements
Inherited Members

Constructors

SshDataStream(byte[])

Initializes a new instance of the SshDataStream class for the specified byte array.

public SshDataStream(byte[] buffer)

Parameters

buffer byte[]

The array of unsigned bytes from which to create the current stream.

Exceptions

ArgumentNullException

buffer is null.

SshDataStream(byte[], int, int)

Initializes a new instance of the SshDataStream class for the specified byte array.

public SshDataStream(byte[] buffer, int offset, int count)

Parameters

buffer byte[]

The array of unsigned bytes from which to create the current stream.

offset int

The zero-based offset in buffer at which to begin reading SSH data.

count int

The number of bytes to load.

Exceptions

ArgumentNullException

buffer is null.

SshDataStream(int)

Initializes a new instance of the SshDataStream class with an expandable capacity initialized as specified.

public SshDataStream(int capacity)

Parameters

capacity int

The initial size of the internal array in bytes.

Properties

IsEndOfData

Gets a value indicating whether all data from the SSH data stream has been read.

public bool IsEndOfData { get; }

Property Value

bool

true if this instance is end of data; otherwise, false.

Methods

ReadBigInt()

Reads a BigInteger from the SSH datastream.

public BigInteger ReadBigInt()

Returns

BigInteger

The BigInteger read from the SSH data stream.

ReadBinary()

Reads a byte array from the SSH data stream.

public byte[] ReadBinary()

Returns

byte[]

The byte array read from the SSH data stream.

ReadString(Encoding)

Reads the next string data type from the SSH data stream.

public string ReadString(Encoding encoding = null)

Parameters

encoding Encoding

The character encoding to use. Defaults to UTF8.

Returns

string

The string read from the SSH data stream.

ReadUInt16()

Reads the next ushort data type from the SSH data stream.

public ushort ReadUInt16()

Returns

ushort

The ushort read from the SSH data stream.

ReadUInt32()

Reads the next uint data type from the SSH data stream.

public uint ReadUInt32()

Returns

uint

The uint read from the SSH data stream.

ReadUInt64()

Reads the next ulong data type from the SSH data stream.

public ulong ReadUInt64()

Returns

ulong

The ulong read from the SSH data stream.

ToArray()

Writes the stream contents to a byte array, regardless of the Position.

public override byte[] ToArray()

Returns

byte[]

This method returns the contents of the SshDataStream as a byte array.

Remarks

If the current instance was constructed on a provided byte array, a copy of the section of the array to which this instance has access is returned.

Write(BigInteger)

Writes a BigInteger into the SSH data stream.

public void Write(BigInteger data)

Parameters

data BigInteger

The BigInteger to write.

Write(byte[])

Writes bytes array data into the SSH data stream.

public void Write(byte[] data)

Parameters

data byte[]

Byte array data to write.

Exceptions

ArgumentNullException

data is null.

Write(string, Encoding)

Writes string data to the SSH data stream using the specified encoding.

public void Write(string s, Encoding encoding)

Parameters

s string

The string data to write.

encoding Encoding

The character encoding to use.

Exceptions

ArgumentNullException

s is null.

ArgumentNullException

encoding is null.

Write(uint)

Writes an uint to the SSH data stream.

public void Write(uint value)

Parameters

value uint

uint data to write.

Write(ulong)

Writes an ulong to the SSH data stream.

public void Write(ulong value)

Parameters

value ulong

ulong data to write.

WriteBinary(byte[])

Writes a buffer preceded by its length into the SSH data stream.

public void WriteBinary(byte[] buffer)

Parameters

buffer byte[]

The data to write.

Exceptions

ArgumentNullException

buffer is null.

WriteBinary(byte[], int, int)

Writes a buffer preceded by its length into the SSH data stream.

public void WriteBinary(byte[] buffer, int offset, int count)

Parameters

buffer byte[]

An array of bytes. This method write count bytes from buffer to the current SSH data stream.

offset int

The zero-based byte offset in buffer at which to begin writing bytes to the SSH data stream.

count int

The number of bytes to be written to the current SSH data stream.

Exceptions

ArgumentNullException

buffer is null.

ArgumentException

The sum of offset and count is greater than the buffer length.

ArgumentOutOfRangeException

offset or count is negative.