I have been using this topic
[SOLVED] Stuck using Synapse tlntsend as SSH client but I have a problem when my internet was disconnected and I want to reconnect it again.
I am using this code for now:
function TTelnetSSHClient.IsAlive: Boolean;
var
tlsfk: TTelnetSend;
begin
tlsfk := TTelnetSend.Create;
tlsfk.TargetPort := TargetPort;
tlsfk.UserName := UserName;
tlsfk.Password := Password;
tlsfk.TargetHost := TargetHost;
tlsfk.Timeout := 500;
if tlsfk.Login then
Result := True
else
Result := False;
tlsfk.Free;
// these thing bellow also used, and nothing happening
//Result := (Sock.Socket = INVALID_SOCKET) or ((Sock.WaitingData = 0) and Sock.CanRead(0));
end;
Does anyone know the better way to check the connection is still alive?