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, IDisposable
Inheritance
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
capacity
int-
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
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 Renci.SshNet.Common.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.
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 datastream.
public BigInteger ReadBigInt()
Returns
- BigInteger
-
The System.Numerics.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 System.String data type from the SSH data stream.
public string ReadString(Encoding encoding = null)
Parameters
encoding
Encoding-
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()
Writes the stream contents to 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
value
uint-
System.UInt32 data to write.
Write(ulong)
Writes an System.UInt64 to the SSH data stream.
public void Write(ulong value)
Parameters
value
ulong-
System.UInt64 data to write.
Write(BigInteger)
Writes a System.Numerics.BigInteger into the SSH data stream.
public void Write(BigInteger data)
Parameters
data
BigInteger-
The System.Numerics.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.
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
andcount
is greater than the buffer length. - ArgumentOutOfRangeException
-
offset
orcount
is negative.