TsgcTCPClient › Properties › TCPKeepAlive
在客户端套接字上启用操作系统级 TCP 保活探测。
property TCPKeepAlive: TsgcTCPKeepAlive read FTCPKeepAlive write SetTCPKeepAlive;
Enabled=False, Time=7200000, Interval=1000
当 TCPKeepAlive.Enabled 为 True 时,传输层通过 SetKeepAliveValues 在套接字上开启 SO_KEEPALIVE 选项。Time 是内核开始探测前的空闲时间(毫秒,默认 7200000,即 2 小时),Interval 是探测之间的间隔(毫秒,默认 1000)。这些探测由操作系统 TCP 栈处理,独立于应用层的 HeartBeat 属性。当您希望以协议无关的方式检测原始 TCP 通道上的死亡对等方时,请使用 TCPKeepAlive。
oTCP := TsgcTCPClient.Create(nil);
oTCP.Host := 'www.esegece.com';
oTCP.Port := 2053;
oTCP.TCPKeepAlive.Time := 60000;
oTCP.TCPKeepAlive.Interval := 5000;
oTCP.TCPKeepAlive.Enabled := true;
oTCP.Active := true;