NetworkStream::Close Method

[This documentation is for preview only, and is subject to change in later releases. Blank topics are included as placeholders.]

Closes the NetworkStream.

Namespace:  System.Net.Sockets
Assembly:  System (in System.dll)

public:
virtual void Close() override

The Close method frees both unmanaged and managed resources associated with the NetworkStream. If the NetworkStream owns the underlying Socket, it is closed as well.

If a NetworkStream was associated with a TcpClient, the Close method will close the TCP connection, but not dispose of the associated TcpClient.

The following code example closes the NetworkStream.


// Example for closing the NetworkStream.
// Close the NetworkStream
myNetworkStream->Close();


Windows 7, Windows Vista, Windows XP SP2, Windows Server 2008, Windows Server 2003, Windows Server 2000 SP4, Windows Millennium Edition, Windows 98, Windows CE, Windows Mobile for Smartphone, Windows Mobile for Pocket PC

The .NET Framework and .NET Compact Framework do not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.

.NET Framework

Supported in: 1.1, 1.0

.NET Compact Framework

Supported in: 1.0
Show: