NetworkStream.Close Method (Int32)

 

Closes the NetworkStream after waiting the specified time to allow data to be sent.

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

public void Close(
	int timeout
)

Parameters

timeout
Type: System.Int32

A 32-bit signed integer that specifies the number of milliseconds to wait to send any remaining data before closing.

Exception Condition
ArgumentOutOfRangeException

The timeout parameter is less than -1.

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.

.NET Framework
Available since 2.0
Return to top
Show: