在TDSTCPServerTransport.OnDisconnect事件中检测Keep-Alive超时

时间:2015-10-29 10:44:35

标签: delphi tcp indy keep-alive datasnap

在DataSnap中,是否可以检测TCP连接是否已关闭,因为已达到保持活动的时间或仅与客户端正常断开连接?

procedure TsrvService.DSTCPServerTransport1Connect(
  Event: TDSTCPConnectEventObject);
begin
  Writeln('Connect from ', Event.Channel.ChannelInfo.ClientInfo.IpAddress);
  Event.Channel.EnableKeepAlive(10000, 100);
end;

procedure TsrvService.DSTCPServerTransport1Disconnect(
  Event: TDSTCPDisconnectEventObject);
begin
  Writeln('Disconnect : ', TIdTcpConnection(Event.Connection).Socket.Binding.PeerIP);
  // Keep-Alive Timeout or any other reason for disconnect???
  // Log('Keep-Alive Timeout for host...');
end;

0 个答案:

没有答案