SocketExtensionsSetKeepAliveValues Method
Enables or disables the per-connection setting of the TCP keep-alive option
which specifies the TCP keep-alive timeout and interval used for TCP keep-alive packets
on the source Socket.
Namespace: DevCase.Extensions.SocketExtensionsAssembly: DevCase.net48 (in DevCase.net48.dll) Version: 6.0.0.0 (6.0)
XMLNS for XAML: Not mapped to an xmlns.
[EditorBrowsableAttribute(EditorBrowsableState.Always)]
public static void SetKeepAliveValues(
this Socket socket,
bool enable,
int timeout,
int interval = 1000
)
<ExtensionAttribute>
<EditorBrowsableAttribute(EditorBrowsableState.Always)>
Public Shared Sub SetKeepAliveValues (
socket As Socket,
enable As Boolean,
timeout As Integer,
Optional interval As Integer = 1000
)
Dim socket As Socket
Dim enable As Boolean
Dim timeout As Integer
Dim interval As Integer
socket.SetKeepAliveValues(enable,
timeout, interval)
public:
[ExtensionAttribute]
[EditorBrowsableAttribute(EditorBrowsableState::Always)]
static void SetKeepAliveValues(
Socket^ socket,
bool enable,
int timeout,
int interval = 1000
)
[<ExtensionAttribute>]
[<EditorBrowsableAttribute(EditorBrowsableState.Always)>]
static member SetKeepAliveValues :
socket : Socket *
enable : bool *
timeout : int *
?interval : int
(* Defaults:
let _interval = defaultArg interval 1000
*)
-> unit
No code example is currently available or this language may not be supported.
- socket Socket
-
The source Socket.
- enable Boolean
-
Enable or disable the TCP keep-alive option.
- timeout Int32
-
The time, in milliseconds, to keep the TCP connection alive since data was last sent.
- interval Int32 (Optional)
-
The interval, in milliseconds, at which keep-alive packets are sent.
Default value is: 1000 (1 second).
In Visual Basic and C#, you can call this method as an instance method on any object of type
Socket. When you use instance method syntax to call this method, omit the first parameter. For more information, see
Extension Methods (Visual Basic) or
Extension Methods (C# Programming Guide).
For more information on the keep-alive option,
see section 4.2.3.6 on the Requirements for Internet HostsCommunication Layers
specified in RFC 1122 available at the IETF website: https://www.ietf.org/rfc/rfc1122.txt
Original C# code: https://stackoverflow.com/a/39664592/1248295