Datasnap 获取客户端IP

uses Data.DBXTransport;

//ServerContainer
procedure TServerContainer.DSServer1Connect(DSConnectEventObject: TDSConnectEventObject);
var
  ci: TDBXClientInfo;
  ClientID: Integer;
begin
  ci := DSConnectEventObject.ChannelInfo.ClientInfo;
  ClientID := DSConnectEventObject.ChannelInfo.Id;
  FrmMain.getUser(IntToStr(ClientID), DateTimeToStr(Now), ci.IpAddress, ci.ClientPort);
end;

//FrmMain
procedure TFrmMain.getUser(strID, strDateTime, strIP, strPort: string);
var
  item: TListItem;
begin
  ListView1.Items.BeginUpdate;
  item := ListView1.Items.Add;
  item.Caption := strDateTime;
  item.SubItems.Add(strID);
  item.SubItems.Add(strIP);
  item.SubItems.Add(strPort);
  ListView1.Items.EndUpdate;
end;

localhost是网页访问rest服务

posted @ 2019-07-27 14:35  liessay  阅读(507)  评论(0编辑  收藏  举报