Export (0) Print
Expand All
This topic has not yet been rated - Rate this topic

LingerOption Constructor

Initializes a new instance of the LingerOption class.

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

public LingerOption (
	bool enable,
	int seconds
)
public LingerOption (
	boolean enable, 
	int seconds
)
public function LingerOption (
	enable : boolean, 
	seconds : int
)

Parameters

enable

true to remain connected after the Socket.Close method is called; otherwise, false.

seconds

The number of seconds to remain connected after the Socket.Close method is called.

There may still be data available in the outgoing network buffer after you close the Socket. Use the enable parameter to specify whether you would like the Socket to continue transmitting unsent data after the close method is called. Use the seconds parameter to indicate how long you would like the Socket to attempt transferring unsent data before timing out. If you specify true for the enable parameter and 0 for the seconds parameter, the Socket will attempt to send data until there is no data left in the outgoing network buffer. If you specify false for the enable parameter, the Socket will close immediately and any unsent data will be lost.

The following example sets a previously created Socket to linger one second after calling the Close method.

LingerOption myOpts = new LingerOption(true,1);

mySocket.SetSocketOption(SocketOptionLevel.Socket, SocketOptionName.Linger, myOpts);


LingerOption myOpts = new LingerOption(true,1);
mySocket.SetSocketOption(SocketOptionLevel.Socket,
    SocketOptionName.Linger, myOpts);

Windows 98, Windows 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 Edition

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

.NET Framework

Supported in: 2.0, 1.1, 1.0

.NET Compact Framework

Supported in: 2.0, 1.0
Did you find this helpful?
(1500 characters remaining)
Thank you for your feedback

Community Additions

ADD
Show:
© 2014 Microsoft. All rights reserved.