Page 1 of 1

Get client IP in OnClientError of SSHserver component

Posted: Fri 14 Jul 2017 19:01
by tcaduto12068
Hi,
How do you get the clients IP and port in the Onclienterror event in the sshserver component?

Re: Get client IP in OnClientError of SSHserver component

Posted: Mon 17 Jul 2017 13:55
by ViktorV
To solve the issue try to use the following code:

Code: Select all

procedure TSSHServerFrame.ScSSHServerClientError(Sender: TObject;
  ClientInfo: TScSSHClientInfo; E: Exception);
var
  IP, Port: string;
  Sock: TIPEndPoint;
begin
  Sock := TIPEndPoint.Create(PSockAddrIn(ClientInfo.SockAddr));
  try
    IP := Sock.ToString;
    Port := IntToStr(Sock.Port)
  finally
    Sock.Free;
  end;
end;