TcpClient.Close Method ()

 

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

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

member Close : unit -> unit

The Close method marks the instance as disposed and requests that the associated Socket close the TCP connection. Based on the LingerState property, the TCP connection may stay open for some time after the 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 Socket and will also close the associated NetworkStream that is used to send and receive data if one was created.

System_CAPS_noteNote

This member outputs trace information when you enable network tracing in your application. For more information, see Network Tracing in the .NET Framework.

The following code example demonstrates closing a TcpClient by calling the Close method.

No code example is currently available or this language may not be supported.

.NET Framework
Available since 1.1
Return to top
Show: