Skip to main content

NetworkStream Class

NuGet: GHIElectronics.TinyCLR.Networking
Assembly: GHIElectronics.TinyCLR.Networking
Namespace: System.Net.Sockets

Provides the underlying stream of data for network access.

public class NetworkStream : Stream

Constructors​

NetworkStream(Socket socket)​

public NetworkStream(Socket socket) : this(socket, false)

Creates a new network stream for the specified socket.

NetworkStream(Socket socket, bool ownsSocket)​

public NetworkStream(Socket socket, bool ownsSocket)

Creates a new network stream for the specified socket, optionally taking ownership of it.

Properties​

CanRead​

public override bool CanRead { get; }

Whether the stream supports reading.

CanSeek​

public override bool CanSeek { get; }

Whether the stream supports seeking; always false.

CanTimeout​

public override bool CanTimeout { get; }

Whether the stream supports timeouts; always true.

CanWrite​

public override bool CanWrite { get; }

Whether the stream supports writing.

ReadTimeout​

public override int ReadTimeout { get; set; }

The amount of time, in milliseconds, that a read operation waits before timing out.

WriteTimeout​

public override int WriteTimeout { get; set; }

The amount of time, in milliseconds, that a write operation waits before timing out.

Length​

public override long Length { get; }

Not supported; always throws NotSupportedException.

Position​

public override long Position { get; set; }

Not supported; always throws NotSupportedException.

DataAvailable​

public override bool DataAvailable { get; }

Whether data is available on the stream to be read.

Methods​

Close(int timeout)​

public void Close(int timeout)

Closes the stream after waiting the specified time for data to be sent.

Dispose(bool disposing)​

protected override void Dispose(bool disposing)

Releases the resources used by the stream.

Flush()​

public override void Flush()

Flushes the stream; reserved for future use.

Read(byte[] buffer, int offset, int count)​

public override int Read(byte[] buffer, int offset, int count)

Reads data from the stream into the buffer and returns the number of bytes read.

Returns int

Seek(long offset, SeekOrigin origin)​

public override long Seek(long offset, SeekOrigin origin)

Not supported; always throws NotSupportedException.

Returns long

SetLength(long value)​

public override void SetLength(long value)

Not supported; always throws NotSupportedException.

Write(byte[] buffer, int offset, int count)​

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

Writes data from the buffer to the stream.

Fields​

_socketType​

protected int _socketType

The type of the underlying socket.

_remoteEndPoint​

protected EndPoint _remoteEndPoint

The remote endpoint used for datagram sockets.

_disposed​

protected bool _disposed

Whether the stream has been disposed.