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
bufferbyte[]The array of unsigned bytes from which to create the current stream.
Exceptions
- ArgumentNullException
bufferis 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
bufferbyte[]The array of unsigned bytes from which to create the current stream.
offsetintThe zero-based offset in
bufferat which to begin reading SSH data.countintThe number of bytes to load.
Exceptions
- ArgumentNullException
bufferis null.
SshDataStream(int)
Initializes a new instance of the SshDataStream class with an expandable capacity initialized as specified.
public SshDataStream(int capacity)
Parameters
capacityintThe 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
dataBigIntegerThe BigInteger to write.
Write(byte[])
Writes bytes array data into the SSH data stream.
public void Write(byte[] data)
Parameters
databyte[]Byte array data to write.
Exceptions
- ArgumentNullException
datais 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
sis null.- ArgumentNullException
encodingis 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
bufferbyte[]The data to write.
Exceptions
- ArgumentNullException
bufferis 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
bufferbyte[]An array of bytes. This method write
countbytes from buffer to the current SSH data stream.offsetintThe zero-based byte offset in
bufferat which to begin writing bytes to the SSH data stream.countintThe number of bytes to be written to the current SSH data stream.
Exceptions
- ArgumentNullException
bufferis null.- ArgumentException
The sum of
offsetandcountis greater than the buffer length.- ArgumentOutOfRangeException
offsetorcountis negative.