有人可以告诉我如何从服务器端获取连接会话的客户端IP吗?
由于
答案 0 :(得分:5)
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;
答案 1 :(得分:3)
您查询Request.RemoteAddr
以获取所连接客户端的IP地址。