/
LingerOption.cs
52 lines (46 loc) · 1.35 KB
/
LingerOption.cs
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
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
namespace System.Net.Sockets
{
// Contains information for a socket's linger time, the amount of time it will
// remain after closing if data remains to be sent.
public class LingerOption
{
private bool _enabled;
private int _lingerTime;
public LingerOption(bool enable, int seconds)
{
Enabled = enable;
LingerTime = seconds;
}
// Enables or disables lingering after close.
public bool Enabled
{
get
{
return _enabled;
}
set
{
_enabled = value;
}
}
// The amount of time, in seconds, to remain connected after a close.
public int LingerTime
{
get
{
return _lingerTime;
}
set
{
_lingerTime = value;
}
}
public override bool Equals(object? comparand)
{
return comparand is LingerOption option && option.Enabled == _enabled && option.LingerTime == _lingerTime;
}
public override int GetHashCode() => HashCode.Combine(_enabled, _lingerTime);
}
}