System.Net.Sockets.LingerOption Class

Assembly: System.dll
Namespace: System.Net.Sockets
Summary
Contains information about a socket's linger time, the amount of time it will remain after closing if data remains to be sent.
C# Syntax:
public class LingerOption
Remarks
The settings of the LingerOption instance associated with a Socket instance control the length of time that a socket will remain after closing if data remains to be sent.

If LingerOption.Enabled is false, calling the Socket.Close method will immediately close the connection to the network. If LingerOption.Enabled is true, data will continue to be sent to the network with a time-out of LingerOption.LingerTime, in seconds. Once the data is sent, or once the time-out expires, the connection is gracefully closed. If no data is in the send queue, the socket is closed immediately.

When LingerOption.Enabled is true and LingerOption.LingerTime is zero, calling Socket.Close will close the socket immediately and lose any unsent data.

Example
The following example sets a previously created Socket instance to linger 1 second after calling Socket.Close.
 LingerOption myOpts = new LingerOption(true,1);
 
 mySocket.SetSocketOption(SocketOptionLevel.IP,SocketOptionName.Linger,myOpts);
 

    
See also:
System.Net.Sockets Namespace

System.Net.Sockets.LingerOption Member List:

Public Constructors
ctor #1 Initializes a new instance of the LingerOption class.
Public Properties
Enabled Read-write

Gets or sets a value indicating whether to linger after the socket is closed.
LingerTime Read-write

Gets or sets the amount of time to remain connected after the socket is closed.
Public Methods
Equals
(inherited from System.Object)
See base class member description: System.Object.Equals

Derived from System.Object, the primary base class for all objects.
GetHashCode
(inherited from System.Object)
See base class member description: System.Object.GetHashCode

Derived from System.Object, the primary base class for all objects.
GetType
(inherited from System.Object)
See base class member description: System.Object.GetType

Derived from System.Object, the primary base class for all objects.
ToString
(inherited from System.Object)
See base class member description: System.Object.ToString

Derived from System.Object, the primary base class for all objects.
Protected Methods
Finalize
(inherited from System.Object)
See base class member description: System.Object.Finalize

Derived from System.Object, the primary base class for all objects.
MemberwiseClone
(inherited from System.Object)
See base class member description: System.Object.MemberwiseClone

Derived from System.Object, the primary base class for all objects.

Hierarchy:


System.Net.Sockets.LingerOption Member Details

ctor #1
Summary
Initializes a new instance of the LingerOption class.
C# Syntax:
public LingerOption(
   bool enable,
   int seconds
);
Parameters:

enable

true to enable remaining connected after Socket.Close is called; otherwise, false.

seconds

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

Remarks
The LingerOption instance is created with LingerOption.Enabled property set to enable and the LingerOption.LingerTime property set to seconds.

Return to top


Property: Enabled (read-write)
Summary
Gets or sets a value indicating whether to linger after the socket is closed.
C# Syntax:
public bool Enabled {get; set;}

Return to top


Property: LingerTime (read-write)
Summary
Gets or sets the amount of time to remain connected after the socket is closed.
C# Syntax:
public int LingerTime {get; set;}

Return to top


Method: Equals(
   object obj
)
Inherited
See base class member description: System.Object.Equals
C# Syntax:
public virtual bool Equals(
   object obj
);

For more information on members inherited from System.Object click on the link above.

Return to top


Method: Finalize()
Inherited
See base class member description: System.Object.Finalize
C# Syntax:
~LingerOption();

For more information on members inherited from System.Object click on the link above.

Return to top


Method: GetHashCode()
Inherited
See base class member description: System.Object.GetHashCode
C# Syntax:
public virtual int GetHashCode();

For more information on members inherited from System.Object click on the link above.

Return to top


Method: GetType()
Inherited
See base class member description: System.Object.GetType
C# Syntax:
public Type GetType();

For more information on members inherited from System.Object click on the link above.

Return to top


Method: MemberwiseClone()
Inherited
See base class member description: System.Object.MemberwiseClone
C# Syntax:
protected object MemberwiseClone();

For more information on members inherited from System.Object click on the link above.

Return to top


Method: ToString()
Inherited
See base class member description: System.Object.ToString
C# Syntax:
public virtual string ToString();

For more information on members inherited from System.Object click on the link above.

Return to top


Top of page

Copyright (c) 2002 Microsoft Corporation. All rights reserved.