How to get the client IP in DataSnap 2010
-
24-09-2019 - |
Question
Someone can tell me how to get the client ip of a connected session from the server side?.
Thanks
Solution
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;
OTHER TIPS
You query the Request.RemoteAddr
to get the ip address of the attached client.
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow