If you are using an updated version of Indy 10, you can use the method TIdSocketHandle.SetKeepAliveValues():
procedure SetKeepAliveValues(const AEnabled: Boolean; const ATimeMS, AInterval: Integer);
For instance:
procedure TForm1.IdHTTPServer1Connect(AContext: TIdContext);
begin
// send a keep-alive every 1 second after
// 5 seconds of inactivity has been detected
AContext.Binding.SetKeepAliveValues(True, 5000, 1000);
end;
Please note that ATimeMSand options AIntervalare only supported in Win2K and later.
TIdSocketHandle.SetSockOpt(), TCP/IP SO_KEEPALIVE :
procedure TIdSocketHandle.SetSockOpt(ALevel: TIdSocketOptionLevel; AOptName: TIdSocketOption; AOptVal: Integer);
:
procedure TForm1.IdHTTPServer1Connect(AContext: TIdContext);
begin
AContext.Binding.SetSockOpt(Id_SOL_SOCKET, Id_SO_KEEPALIVE, 1);
end;