Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to get the client IP in DataSnap 2010

Someone can tell me how to get the client ip of a connected session from the server side?.

Thanks

like image 269
Francis Lee Avatar asked Feb 28 '23 16:02

Francis Lee


2 Answers

procedure TMyDSService.DataSnapServerConnect(DSConnectEventObject: TDSConnectEventObject);
var
  Conn: TIdTCPConnection;
begin
   Conn := TIdTCPConnection(DSConnectEventObject.ChannelInfo.Id);
   Trace('Client ' + Conn.Socket.Binding.PeerIP +':' + IntToStr(Conn.Socket.Binding.PeerPort));
   Trace('Client info: ' + DSConnectEventObject.ChannelInfo.Info);
end;
like image 60
Mike Avatar answered Mar 02 '23 08:03

Mike


You query the Request.RemoteAddr to get the ip address of the attached client.

like image 31
skamradt Avatar answered Mar 02 '23 06:03

skamradt