有人可以告诉我如何从服务器端获取连接 session 的客户端 IP?
谢谢
最佳答案
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;