Socket.Close Method (Int32)
Assembly: System (in system.dll)
For connection-oriented protocols, it is recommended that you call Shutdown before calling Close. This ensures that all data is sent and received on the connected socket before it is closed.
If you need to call Close without first calling Shutdown, you can ensure that data queued for outgoing transmission will be sent by setting the DontLinger option to false and specifying a non-zero time-out interval. Close will then block until this data is sent or until the specified time-out expires. If you set DontLinger to false and specify a zero time-out interval, Close releases the connection and automatically discards outgoing queued data.
To set the DontLinger socket option to false, create a LingerOption, set the enabled property to true, and set the LingerTime property to the desired time-out period. Use this LingerOption along with the DontLinger socket option to call the SetSocketOption method.
This member outputs trace information when you enable network tracing in your application. For more information, see Network Tracing.
Windows 98, Windows Server 2000 SP4, Windows CE, Windows Millennium Edition, Windows Mobile for Pocket PC, Windows Mobile for Smartphone, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter EditionThe Microsoft .NET Framework 3.0 is supported on Windows Vista, Microsoft Windows XP SP2, and Windows Server 2003 SP1.