System.Net.Sockets.TcpClient.Close Method

Disposes this System.Net.Sockets.TcpClient instance and requests that the underlying TCP connection be closed.

Syntax

public void Close ()

Remarks

The TcpClient.Close method marks the instance as disposed and requests that the associated System.Net.Sockets.Socket close the TCP connection. Based on the TcpClient.LingerState property, the TCP connection may stay open for some time after the TcpClient.Close method is called when data remains to be sent. There is no notification provided when the underlying connection has completed closing.

Calling this method will eventually result in the close of the associated System.Net.Sockets.Socket and will also close the associated System.Net.Sockets.NetworkStream that is used to send and receive data if one was created.

Note:

This member outputs trace information when you enable network tracing in your application. For more information, see [<topic://conUsingNetworkTracing>].

Requirements

Namespace: System.Net.Sockets
Assembly: System (in System.dll)
Assembly Versions: 1.0.5000.0, 2.0.0.0, 4.0.0.0