Class SshDataStream
- Namespace
- Renci.SshNet.Common
- Assembly
- Renci.SshNet.dll
Specialized System.IO.MemoryStream for reading and writing data SSH data.
public class SshDataStream : MemoryStream, IAsyncDisposable, IDisposableInheritance
Implements
Inherited Members
Constructors
SshDataStream(int)
Initializes a new instance of the Renci.SshNet.Common.SshDataStream class with an expandable capacity initialized as specified.
public SshDataStream(int capacity)Parameters
capacityint-
The initial size of the internal array in bytes.
SshDataStream(byte[])
Initializes a new instance of the Renci.SshNet.Common.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 Renci.SshNet.Common.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.
offsetint-
The zero-based offset in
bufferat which to begin reading SSH data. countint-
The number of bytes to load.
Exceptions
- ArgumentNullException
-
bufferis null.
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 System.Numerics.BigInteger from the SSH data stream.
public BigInteger ReadBigInt()Returns
- BigInteger
-
The System.Numerics.BigInteger read from the SSH data stream.
ReadBinary()
Reads a length-prefixed 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 System.String data type from the SSH data stream.
public string ReadString(Encoding encoding = null)Parameters
encodingEncoding-
The character encoding to use. Defaults to System.Text.Encoding.UTF8.
Returns
- string
-
The System.String read from the SSH data stream.
ReadUInt16()
Reads the next System.UInt16 data type from the SSH data stream.
public ushort ReadUInt16()Returns
- ushort
-
The System.UInt16 read from the SSH data stream.
ReadUInt32()
Reads the next System.UInt32 data type from the SSH data stream.
public uint ReadUInt32()Returns
- uint
-
The System.UInt32 read from the SSH data stream.
ReadUInt64()
Reads the next System.UInt64 data type from the SSH data stream.
public ulong ReadUInt64()Returns
- ulong
-
The System.UInt64 read from the SSH data stream.
ToArray()
Retrieves the stream contents as a byte array, regardless of the System.IO.MemoryStream.Position.
public override byte[] ToArray()Returns
- byte[]
-
This method returns the contents of the Renci.SshNet.Common.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(uint)
Writes an System.UInt32 to the SSH data stream.
public void Write(uint value)Parameters
valueuint-
System.UInt32 data to write.
Write(ulong)
Writes an System.UInt64 to the SSH data stream.
public void Write(ulong value)Parameters
valueulong-
System.UInt64 data to write.
Write(BigInteger)
Writes a System.Numerics.BigInteger into the SSH data stream.
public void Write(BigInteger data)Parameters
dataBigInteger-
The System.Numerics.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.
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. offsetint-
The zero-based byte offset in
bufferat which to begin writing bytes to the SSH data stream. countint-
The 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.