-
Notifications
You must be signed in to change notification settings - Fork 1.5k
/
LingerOption.xml
353 lines (319 loc) · 25.4 KB
/
LingerOption.xml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
<Type Name="LingerOption" FullName="System.Net.Sockets.LingerOption">
<TypeSignature Language="C#" Value="public class LingerOption" />
<TypeSignature Language="ILAsm" Value=".class public auto ansi beforefieldinit LingerOption extends System.Object" />
<TypeSignature Language="DocId" Value="T:System.Net.Sockets.LingerOption" />
<TypeSignature Language="VB.NET" Value="Public Class LingerOption" />
<TypeSignature Language="F#" Value="type LingerOption = class" />
<TypeSignature Language="C++ CLI" Value="public ref class LingerOption" />
<AssemblyInfo>
<AssemblyName>System.Net.Sockets</AssemblyName>
<AssemblyVersion>4.1.0.0</AssemblyVersion>
<AssemblyVersion>4.2.0.0</AssemblyVersion>
<AssemblyVersion>4.2.1.0</AssemblyVersion>
<AssemblyVersion>4.2.2.0</AssemblyVersion>
<AssemblyVersion>5.0.0.0</AssemblyVersion>
<AssemblyVersion>6.0.0.0</AssemblyVersion>
<AssemblyVersion>7.0.0.0</AssemblyVersion>
<AssemblyVersion>8.0.0.0</AssemblyVersion>
<AssemblyVersion>9.0.0.0</AssemblyVersion>
</AssemblyInfo>
<AssemblyInfo>
<AssemblyName>System</AssemblyName>
<AssemblyVersion>1.0.5000.0</AssemblyVersion>
<AssemblyVersion>2.0.0.0</AssemblyVersion>
<AssemblyVersion>2.0.5.0</AssemblyVersion>
<AssemblyVersion>4.0.0.0</AssemblyVersion>
</AssemblyInfo>
<AssemblyInfo>
<AssemblyName>netstandard</AssemblyName>
<AssemblyVersion>2.0.0.0</AssemblyVersion>
<AssemblyVersion>2.1.0.0</AssemblyVersion>
</AssemblyInfo>
<TypeForwardingChain>
<TypeForwarding From="netstandard" FromVersion="2.1.0.0" To="System.Net.Sockets" ToVersion="5.0.0.0" FrameworkAlternate="net-5.0" />
<TypeForwarding From="netstandard" FromVersion="2.1.0.0" To="System.Net.Sockets" ToVersion="6.0.0.0" FrameworkAlternate="net-6.0" />
<TypeForwarding From="netstandard" FromVersion="2.1.0.0" To="System.Net.Sockets" ToVersion="7.0.0.0" FrameworkAlternate="net-7.0" />
<TypeForwarding From="netstandard" FromVersion="2.1.0.0" To="System.Net.Sockets" ToVersion="8.0.0.0" FrameworkAlternate="net-8.0" />
<TypeForwarding From="netstandard" FromVersion="2.1.0.0" To="System.Net.Sockets" ToVersion="9.0.0.0" FrameworkAlternate="net-9.0" />
</TypeForwardingChain>
<Base>
<BaseTypeName>System.Object</BaseTypeName>
</Base>
<Interfaces />
<Docs>
<summary>Specifies whether a <see cref="T:System.Net.Sockets.Socket" /> will remain connected after a call to the <see cref="M:System.Net.Sockets.Socket.Close" /> or <see cref="M:System.Net.Sockets.TcpClient.Close" /> methods and the length of time it will remain connected, if data remains to be sent.</summary>
<remarks>
<format type="text/markdown"><![CDATA[
## Remarks
There may still be data available in the outgoing network buffer after an application calls the <xref:System.Net.Sockets.Socket> or <xref:System.Net.Sockets.TcpClient> method. If you want to specify the amount of time that the <xref:System.Net.Sockets.Socket> will attempt to transmit unsent data after closing, create a <xref:System.Net.Sockets.LingerOption> with the `enable` parameter set to `true`, and the `seconds` parameter set to the desired amount of time. The `seconds` parameter is used to indicate how long you would like the <xref:System.Net.Sockets.Socket> to remain connected before timing out. If you do not want the <xref:System.Net.Sockets.Socket> to stay connected for any length of time after closing, create a <xref:System.Net.Sockets.LingerOption> instance with the `enable` parameter set to `true` and the `seconds` parameter set to zero. In this case, the <xref:System.Net.Sockets.Socket> will close immediately and any unsent data will be lost. Once created, pass the <xref:System.Net.Sockets.LingerOption> to the <xref:System.Net.Sockets.Socket.SetSocketOption%2A?displayProperty=nameWithType> method. If you are sending and receiving data with a <xref:System.Net.Sockets.TcpClient>, then set the <xref:System.Net.Sockets.LingerOption> instance in the <xref:System.Net.Sockets.TcpClient.LingerState%2A?displayProperty=nameWithType> property.
The IP stack computes the default IP protocol time-out period to use based on the round trip time of the connection. In most cases, the time-out computed by the stack is more relevant than one defined by an application. This is the default behavior for a <xref:System.Net.Sockets.Socket> when the <xref:System.Net.Sockets.Socket.LingerState%2A> property is not set and for a <xref:System.Net.Sockets.TcpClient> when the <xref:System.Net.Sockets.TcpClient.LingerState%2A> property is not set.
## Examples
The following example sets a previously created <xref:System.Net.Sockets.Socket> to linger one second after calling the <xref:System.Net.Sockets.Socket.Close%2A> method.
:::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/Classic LingerOption Example/CPP/source.cpp" id="Snippet1":::
:::code language="csharp" source="~/snippets/csharp/System.Net.Sockets/LingerOption/Overview/source.cs" id="Snippet1":::
:::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/Classic LingerOption Example/VB/source.vb" id="Snippet1":::
]]></format>
</remarks>
</Docs>
<Members>
<Member MemberName=".ctor">
<MemberSignature Language="C#" Value="public LingerOption (bool enable, int seconds);" />
<MemberSignature Language="ILAsm" Value=".method public hidebysig specialname rtspecialname instance void .ctor(bool enable, int32 seconds) cil managed" />
<MemberSignature Language="DocId" Value="M:System.Net.Sockets.LingerOption.#ctor(System.Boolean,System.Int32)" />
<MemberSignature Language="VB.NET" Value="Public Sub New (enable As Boolean, seconds As Integer)" />
<MemberSignature Language="F#" Value="new System.Net.Sockets.LingerOption : bool * int -> System.Net.Sockets.LingerOption" Usage="new System.Net.Sockets.LingerOption (enable, seconds)" />
<MemberSignature Language="C++ CLI" Value="public:
 LingerOption(bool enable, int seconds);" />
<MemberType>Constructor</MemberType>
<AssemblyInfo>
<AssemblyName>System.Net.Sockets</AssemblyName>
<AssemblyVersion>4.1.0.0</AssemblyVersion>
<AssemblyVersion>4.2.0.0</AssemblyVersion>
<AssemblyVersion>4.2.1.0</AssemblyVersion>
<AssemblyVersion>4.2.2.0</AssemblyVersion>
<AssemblyVersion>5.0.0.0</AssemblyVersion>
<AssemblyVersion>6.0.0.0</AssemblyVersion>
<AssemblyVersion>7.0.0.0</AssemblyVersion>
<AssemblyVersion>8.0.0.0</AssemblyVersion>
<AssemblyVersion>9.0.0.0</AssemblyVersion>
</AssemblyInfo>
<AssemblyInfo>
<AssemblyName>System</AssemblyName>
<AssemblyVersion>1.0.5000.0</AssemblyVersion>
<AssemblyVersion>2.0.0.0</AssemblyVersion>
<AssemblyVersion>2.0.5.0</AssemblyVersion>
<AssemblyVersion>4.0.0.0</AssemblyVersion>
</AssemblyInfo>
<AssemblyInfo>
<AssemblyName>netstandard</AssemblyName>
<AssemblyVersion>2.0.0.0</AssemblyVersion>
<AssemblyVersion>2.1.0.0</AssemblyVersion>
</AssemblyInfo>
<Parameters>
<Parameter Name="enable" Type="System.Boolean" />
<Parameter Name="seconds" Type="System.Int32" />
</Parameters>
<Docs>
<param name="enable">
<see langword="true" /> to remain connected after the <see cref="M:System.Net.Sockets.Socket.Close" /> method is called; otherwise, <see langword="false" />.</param>
<param name="seconds">The number of seconds to remain connected after the <see cref="M:System.Net.Sockets.Socket.Close" /> method is called.</param>
<summary>Initializes a new instance of the <see cref="T:System.Net.Sockets.LingerOption" /> class.</summary>
<remarks>
<format type="text/markdown"><![CDATA[
## Remarks
There may still be data available in the outgoing network buffer after you close the <xref:System.Net.Sockets.Socket>. Use the `enable` parameter to specify whether you would like the <xref:System.Net.Sockets.Socket> to continue transmitting unsent data after the close method is called. Use the `seconds` parameter to indicate how long you would like the <xref:System.Net.Sockets.Socket> to attempt transferring unsent data before timing out. If you specify `true` for the `enable` parameter and 0 for the `seconds` parameter, the <xref:System.Net.Sockets.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 <xref:System.Net.Sockets.Socket> will close immediately and any unsent data will be lost.
The following table describes the behavior on the <xref:System.Net.Sockets.Socket.Close%2A?displayProperty=nameWithType> and <xref:System.Net.Sockets.TcpClient.Close%2A?displayProperty=nameWithType> methods based on the possible values of the `enable` and `seconds` parameters when an T:System.Net.Sockets.LingerOption instance is created and set in the <xref:System.Net.Sockets.Socket.LingerState%2A?displayProperty=nameWithType> or <xref:System.Net.Sockets.TcpClient.LingerState%2A?displayProperty=nameWithType> property.
|`enable`|`seconds`|Behavior|
|--------------|---------------|--------------|
|`false` (disabled), the default value|The time-out is not applicable, (default).|Attempts to send pending data for a connection-oriented socket (TCP, for example) until the default IP protocol time-out expires.|
|`true` (enabled)|A nonzero time-out|Attempts to send pending data until the specified time-out expires, and if the attempt fails, then Winsock resets the connection.|
|`true` (enabled)|A zero timeout.|Discards any pending data. For connection-oriented socket (TCP, for example), Winsock resets the connection.|
The IP stack computes the default IP protocol time-out period to use based on the round trip time of the connection. In most cases, the time-out computed by the stack is more relevant than one defined by an application. This is the default behavior for a socket when the <xref:System.Net.Sockets.Socket.LingerState%2A> property is not set.
When the <xref:System.Net.Sockets.LingerOption.LingerTime%2A> property stored in the <xref:System.Net.Sockets.Socket.LingerState%2A> property is set greater than the default IP protocol time-out, the default IP protocol time-out will still apply and override.
## Examples
The following example sets a previously created <xref:System.Net.Sockets.Socket> to linger one second after calling the <xref:System.Net.Sockets.Socket.Close%2A> method.
:::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/Classic LingerOption Example/CPP/source.cpp" id="Snippet1":::
:::code language="csharp" source="~/snippets/csharp/System.Net.Sockets/LingerOption/Overview/source.cs" id="Snippet1":::
:::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/Classic LingerOption Example/VB/source.vb" id="Snippet1":::
]]></format>
</remarks>
</Docs>
</Member>
<Member MemberName="Enabled">
<MemberSignature Language="C#" Value="public bool Enabled { get; set; }" />
<MemberSignature Language="ILAsm" Value=".property instance bool Enabled" />
<MemberSignature Language="DocId" Value="P:System.Net.Sockets.LingerOption.Enabled" />
<MemberSignature Language="VB.NET" Value="Public Property Enabled As Boolean" />
<MemberSignature Language="F#" Value="member this.Enabled : bool with get, set" Usage="System.Net.Sockets.LingerOption.Enabled" />
<MemberSignature Language="C++ CLI" Value="public:
 property bool Enabled { bool get(); void set(bool value); };" />
<MemberType>Property</MemberType>
<AssemblyInfo>
<AssemblyName>System.Net.Sockets</AssemblyName>
<AssemblyVersion>4.1.0.0</AssemblyVersion>
<AssemblyVersion>4.2.0.0</AssemblyVersion>
<AssemblyVersion>4.2.1.0</AssemblyVersion>
<AssemblyVersion>4.2.2.0</AssemblyVersion>
<AssemblyVersion>5.0.0.0</AssemblyVersion>
<AssemblyVersion>6.0.0.0</AssemblyVersion>
<AssemblyVersion>7.0.0.0</AssemblyVersion>
<AssemblyVersion>8.0.0.0</AssemblyVersion>
<AssemblyVersion>9.0.0.0</AssemblyVersion>
</AssemblyInfo>
<AssemblyInfo>
<AssemblyName>System</AssemblyName>
<AssemblyVersion>1.0.5000.0</AssemblyVersion>
<AssemblyVersion>2.0.0.0</AssemblyVersion>
<AssemblyVersion>2.0.5.0</AssemblyVersion>
<AssemblyVersion>4.0.0.0</AssemblyVersion>
</AssemblyInfo>
<AssemblyInfo>
<AssemblyName>netstandard</AssemblyName>
<AssemblyVersion>2.0.0.0</AssemblyVersion>
<AssemblyVersion>2.1.0.0</AssemblyVersion>
</AssemblyInfo>
<Attributes>
<Attribute FrameworkAlternate="netframework-4.0">
<AttributeName Language="C#">[get: System.Runtime.TargetedPatchingOptOut("Performance critical to inline this type of method across NGen image boundaries")]</AttributeName>
<AttributeName Language="F#">[<get: System.Runtime.TargetedPatchingOptOut("Performance critical to inline this type of method across NGen image boundaries")>]</AttributeName>
</Attribute>
<Attribute FrameworkAlternate="netframework-4.0">
<AttributeName Language="C#">[set: System.Runtime.TargetedPatchingOptOut("Performance critical to inline this type of method across NGen image boundaries")]</AttributeName>
<AttributeName Language="F#">[<set: System.Runtime.TargetedPatchingOptOut("Performance critical to inline this type of method across NGen image boundaries")>]</AttributeName>
</Attribute>
</Attributes>
<ReturnValue>
<ReturnType>System.Boolean</ReturnType>
</ReturnValue>
<Docs>
<summary>Gets or sets a value that indicates whether to linger after the <see cref="T:System.Net.Sockets.Socket" /> is closed.</summary>
<value>
<see langword="true" /> if the <see cref="T:System.Net.Sockets.Socket" /> should linger after <see cref="M:System.Net.Sockets.Socket.Close" /> is called; otherwise, <see langword="false" />.</value>
<remarks>
<format type="text/markdown"><![CDATA[
## Remarks
You can use the <xref:System.Net.Sockets.LingerOption.Enabled%2A> property to determine whether the <xref:System.Net.Sockets.Socket> will linger after closing. Change this value to `true` or `false` and pass the altered <xref:System.Net.Sockets.LingerOption> to the <xref:System.Net.Sockets.Socket.SetSocketOption%2A> method or set the <xref:System.Net.Sockets.TcpClient.LingerState%2A> or <xref:System.Net.Sockets.Socket.LingerState%2A> property.to disable or enable lingering.
The following table describes the behavior for the possible values of the <xref:System.Net.Sockets.LingerOption.Enabled%2A> property and the <xref:System.Net.Sockets.LingerOption.LingerTime%2A> property stored in the <xref:System.Net.Sockets.Socket.LingerState%2A> property.
|`enable`|`seconds`|Behavior|
|--------------|---------------|--------------|
|`false` (disabled), the default value|The time-out is not applicable, (default).|Attempts to send pending data for a connection-oriented socket (TCP, for example) until the default IP protocol time-out expires.|
|`true` (enabled)|A nonzero time-out|Attempts to send pending data until the specified time-out expires, and if the attempt fails, then Winsock resets the connection.|
|`true` (enabled)|A zero timeout.|Discards any pending data. For connection-oriented socket (TCP, for example), Winsock resets the connection.|
The IP stack computes the default IP protocol time-out period to use based on the round trip time of the connection. In most cases, the time-out computed by the stack is more relevant than one defined by an application. This is the default behavior for a socket when the <xref:System.Net.Sockets.Socket.LingerState%2A> property is not set.
When the <xref:System.Net.Sockets.LingerOption.LingerTime%2A> property stored in the <xref:System.Net.Sockets.Socket.LingerState%2A> property is set greater than the default IP protocol time-out, the default IP protocol time-out will still apply and override.
]]></format>
</remarks>
</Docs>
</Member>
<Member MemberName="Equals">
<MemberSignature Language="C#" Value="public override bool Equals (object? comparand);" />
<MemberSignature Language="ILAsm" Value=".method public hidebysig virtual instance bool Equals(object comparand) cil managed" />
<MemberSignature Language="DocId" Value="M:System.Net.Sockets.LingerOption.Equals(System.Object)" />
<MemberSignature Language="VB.NET" Value="Public Overrides Function Equals (comparand As Object) As Boolean" />
<MemberSignature Language="F#" Value="override this.Equals : obj -> bool" Usage="lingerOption.Equals comparand" />
<MemberSignature Language="C++ CLI" Value="public:
 override bool Equals(System::Object ^ comparand);" />
<MemberType>Method</MemberType>
<AssemblyInfo>
<AssemblyName>System.Net.Sockets</AssemblyName>
<AssemblyVersion>8.0.0.0</AssemblyVersion>
<AssemblyVersion>9.0.0.0</AssemblyVersion>
</AssemblyInfo>
<AssemblyInfo>
<AssemblyName>netstandard</AssemblyName>
</AssemblyInfo>
<Attributes>
<Attribute FrameworkAlternate="net-8.0;net-9.0">
<AttributeName Language="C#">[System.Runtime.CompilerServices.NullableContext(2)]</AttributeName>
<AttributeName Language="F#">[<System.Runtime.CompilerServices.NullableContext(2)>]</AttributeName>
</Attribute>
</Attributes>
<ReturnValue>
<ReturnType>System.Boolean</ReturnType>
</ReturnValue>
<Parameters>
<Parameter Name="comparand" Type="System.Object" Index="0" FrameworkAlternate="net-8.0;net-9.0" />
</Parameters>
<Docs>
<param name="comparand">The object to compare with the current <see cref="T:System.Net.Sockets.LingerOption" /> instance.</param>
<summary>Determines whether the specified object is equal to the current <see cref="T:System.Net.Sockets.LingerOption" /> instance.</summary>
<returns>
<see langword="true" /> if the specified object is equal to the current <see cref="T:System.Net.Sockets.LingerOption" /> instance; otherwise, <see langword="false" />.</returns>
<remarks>To be added.</remarks>
</Docs>
</Member>
<Member MemberName="GetHashCode">
<MemberSignature Language="C#" Value="public override int GetHashCode ();" />
<MemberSignature Language="ILAsm" Value=".method public hidebysig virtual instance int32 GetHashCode() cil managed" />
<MemberSignature Language="DocId" Value="M:System.Net.Sockets.LingerOption.GetHashCode" />
<MemberSignature Language="VB.NET" Value="Public Overrides Function GetHashCode () As Integer" />
<MemberSignature Language="F#" Value="override this.GetHashCode : unit -> int" Usage="lingerOption.GetHashCode " />
<MemberSignature Language="C++ CLI" Value="public:
 override int GetHashCode();" />
<MemberType>Method</MemberType>
<AssemblyInfo>
<AssemblyName>System.Net.Sockets</AssemblyName>
<AssemblyVersion>8.0.0.0</AssemblyVersion>
<AssemblyVersion>9.0.0.0</AssemblyVersion>
</AssemblyInfo>
<AssemblyInfo>
<AssemblyName>netstandard</AssemblyName>
</AssemblyInfo>
<ReturnValue>
<ReturnType>System.Int32</ReturnType>
</ReturnValue>
<Parameters />
<Docs>
<summary>Returns a hash value for a <see cref="T:System.Net.Sockets.LingerOption" /> instance.</summary>
<returns>An integer hash value.</returns>
<remarks>To be added.</remarks>
</Docs>
</Member>
<Member MemberName="LingerTime">
<MemberSignature Language="C#" Value="public int LingerTime { get; set; }" />
<MemberSignature Language="ILAsm" Value=".property instance int32 LingerTime" />
<MemberSignature Language="DocId" Value="P:System.Net.Sockets.LingerOption.LingerTime" />
<MemberSignature Language="VB.NET" Value="Public Property LingerTime As Integer" />
<MemberSignature Language="F#" Value="member this.LingerTime : int with get, set" Usage="System.Net.Sockets.LingerOption.LingerTime" />
<MemberSignature Language="C++ CLI" Value="public:
 property int LingerTime { int get(); void set(int value); };" />
<MemberType>Property</MemberType>
<AssemblyInfo>
<AssemblyName>System.Net.Sockets</AssemblyName>
<AssemblyVersion>4.1.0.0</AssemblyVersion>
<AssemblyVersion>4.2.0.0</AssemblyVersion>
<AssemblyVersion>4.2.1.0</AssemblyVersion>
<AssemblyVersion>4.2.2.0</AssemblyVersion>
<AssemblyVersion>5.0.0.0</AssemblyVersion>
<AssemblyVersion>6.0.0.0</AssemblyVersion>
<AssemblyVersion>7.0.0.0</AssemblyVersion>
<AssemblyVersion>8.0.0.0</AssemblyVersion>
<AssemblyVersion>9.0.0.0</AssemblyVersion>
</AssemblyInfo>
<AssemblyInfo>
<AssemblyName>System</AssemblyName>
<AssemblyVersion>1.0.5000.0</AssemblyVersion>
<AssemblyVersion>2.0.0.0</AssemblyVersion>
<AssemblyVersion>2.0.5.0</AssemblyVersion>
<AssemblyVersion>4.0.0.0</AssemblyVersion>
</AssemblyInfo>
<AssemblyInfo>
<AssemblyName>netstandard</AssemblyName>
<AssemblyVersion>2.0.0.0</AssemblyVersion>
<AssemblyVersion>2.1.0.0</AssemblyVersion>
</AssemblyInfo>
<Attributes>
<Attribute FrameworkAlternate="netframework-4.0">
<AttributeName Language="C#">[get: System.Runtime.TargetedPatchingOptOut("Performance critical to inline this type of method across NGen image boundaries")]</AttributeName>
<AttributeName Language="F#">[<get: System.Runtime.TargetedPatchingOptOut("Performance critical to inline this type of method across NGen image boundaries")>]</AttributeName>
</Attribute>
<Attribute FrameworkAlternate="netframework-4.0">
<AttributeName Language="C#">[set: System.Runtime.TargetedPatchingOptOut("Performance critical to inline this type of method across NGen image boundaries")]</AttributeName>
<AttributeName Language="F#">[<set: System.Runtime.TargetedPatchingOptOut("Performance critical to inline this type of method across NGen image boundaries")>]</AttributeName>
</Attribute>
</Attributes>
<ReturnValue>
<ReturnType>System.Int32</ReturnType>
</ReturnValue>
<Docs>
<summary>Gets or sets the amount of time to remain connected after calling the <see cref="M:System.Net.Sockets.Socket.Close" /> method if data remains to be sent.</summary>
<value>The amount of time, in seconds, to remain connected after calling <see cref="M:System.Net.Sockets.Socket.Close" />.</value>
<remarks>
<format type="text/markdown"><![CDATA[
## Remarks
Use this value if you want to determine how long a closed <xref:System.Net.Sockets.Socket> will attempt to transfer unsent data before timing out. You can also set this value to the desired time-out period, in seconds.
If the <xref:System.Net.Sockets.LingerOption.Enabled%2A> property is `true`, and you set <xref:System.Net.Sockets.LingerOption.LingerTime%2A> to 0, the <xref:System.Net.Sockets.Socket> discards any pending data to send in the outgoing network buffer. If you change this value, you must pass the altered <xref:System.Net.Sockets.LingerOption> instance to the <xref:System.Net.Sockets.Socket.SetSocketOption%2A> method or set the <xref:System.Net.Sockets.TcpClient.LingerState%2A> or <xref:System.Net.Sockets.Socket.LingerState%2A> property.
The following table describes the behavior for the possible values of the <xref:System.Net.Sockets.LingerOption.Enabled%2A> property and the <xref:System.Net.Sockets.LingerOption.LingerTime%2A> property stored in the <xref:System.Net.Sockets.Socket.LingerState%2A> property.
|`enable`|`seconds`|Behavior|
|--------------|---------------|--------------|
|`false` (disabled), the default value|The time-out is not applicable, (default).|Attempts to send pending data for a connection-oriented socket (TCP, for example) until the default IP protocol time-out expires.|
|`true` (enabled)|A nonzero time-out|Attempts to send pending data until the specified time-out expires, and if the attempt fails, then Winsock resets the connection.|
|`true` (enabled)|A zero timeout.|Discards any pending data. For connection-oriented socket (TCP, for example), Winsock resets the connection.|
The IP stack computes the default IP protocol time-out period to use based on the round trip time of the connection. In most cases, the time-out computed by the stack is more relevant than one defined by an application. This is the default behavior for a socket when the <xref:System.Net.Sockets.Socket.LingerState%2A> property is not set.
When the <xref:System.Net.Sockets.LingerOption.LingerTime%2A> property stored in the <xref:System.Net.Sockets.Socket.LingerState%2A> property is set greater than the default IP protocol time-out, the default IP protocol time-out will still apply and override.
## Examples
The following example displays the value of this property.
:::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/Socket_Socket_Options/CPP/source.cpp" id="Snippet2":::
:::code language="csharp" source="~/snippets/csharp/System.Net.Sockets/LingerOption/LingerTime/source.cs" id="Snippet2":::
:::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/Socket_Socket_Options/VB/source.vb" id="Snippet2":::
]]></format>
</remarks>
</Docs>
</Member>
</Members>
</Type>