SocketTools .NET Edition

SocketWrench.KeepAlive Property

Gets and sets a value which indicates if keep-alive packets are sent on a connected socket.

[Visual Basic]
Public Property KeepAlive As Boolean
[C#]
public bool KeepAlive {get; set;}

Property Value

Returns true if keep-alive packets are sent when the connection is idle, otherwise returns false. The default value is false.

Remarks

Setting the KeepAlive property to a value of true specifies that special packets are to be sent to the remote system when no data is being exchanged to ensure the connection remains active. This property can only be set for sockets that were created with the Protocol property set to a value of SocketProtocol.protocolStream.

If this property is set to true, keep-alive packets will start being generated five seconds after the socket has become idle with no data being sent or received. Enabling this option can be used by applications to detect when a physical network connection has been lost. However, it is recommended that most applications query the remote host directly to determine if the connection is still active. This is typically accomplished by sending specific commands to the server to query its status, or checking the elapsed time since the last response from the server.

See Also