NetworkStream Class (NET)

Represents a connection that can be used to send and receive data over a TCP stream.

Summary

The NetworkStream class provides a TCP stream that you can use to send and receive data over a network. It is part of the System.Net.Sockets namespace.

Properties

Property Name Description
TcpClient The associated TcpClient object.
BytesReceived The number of bytes received from the stream.
BytesWritten The number of bytes written to the stream.

Methods

Method Name Description
Read() Reads a block of data from the stream.
Write() Writes a block of data to the stream.
Dispose() Releases the resources used by the stream.

Example

using System; using System.IO; using System.Net.Sockets; public class Example { public static void Main(string[] args) { // ... (Code to create and use NetworkStream) ... } }