Class SshDataStream
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
intThe zero-based offset in
buffer
at which to begin reading SSH data.count
intThe 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
intThe 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
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
Returns
ReadUInt16()
Reads the next ushort data type from the SSH data stream.
public ushort ReadUInt16()
Returns
ReadUInt32()
Reads the next uint data type from the SSH data stream.
public uint ReadUInt32()
Returns
ReadUInt64()
Reads the next ulong data type from the SSH data stream.
public ulong ReadUInt64()
Returns
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
BigIntegerThe 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
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
Write(ulong)
Writes an ulong to the SSH data stream.
public void Write(ulong value)
Parameters
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
intThe zero-based byte offset in
buffer
at which to begin writing bytes to the SSH data stream.count
intThe number of bytes to be written to the current SSH data stream.
Exceptions
- ArgumentNullException
buffer
is null.- ArgumentException
The sum of
offset
andcount
is greater than the buffer length.- ArgumentOutOfRangeException
offset
orcount
is negative.