DataSnap伺服器如何得到客戶端的IP和埠

2021-06-09 01:56:19 字數 1277 閱讀 3098

作為乙個伺服器軟體,必須做到對客戶端強有力的控制,想要控制,就必須得到客戶端的網路基本資訊,比如客戶端ip和埠。有了客戶端ip就能隨心所欲操控客戶端,比如終止某些客戶端的連線、限制功能等等。

在delphi2010中的datasnap伺服器如何獲得客戶端ip,的確花了我點時間,奇怪為什麼這個功能不做的更人性化點呢,功能總是藏著掖著。還得讓程式設計師像尋寶一樣摸索,浪費時間。現在把我整理的結果奉獻給大家,免得大家在花時間研究這個。

另外,通過研究發現,dsconnecteventobject.channelinfo.id 屬性實際上是記憶體位址,並不是乙個簡單的數字。

以下**紅色部分是關鍵。

uses idtcpconnection;

if dsconnecteventobject.channelinfo <> nil then

begin

clientconnection := tidtcpconnection(dsconnecteventobject.channelinfo.id);

dsshowdataset['clientid'] := dsconnecteventobject.channelinfo.id;

dsshowdataset['clientip'] := clientconnection.socket.binding.peerip +

':' + inttostr(clientconnection.socket.binding.peerport);

dsshowdataset['serverip'] := clientconnection.socket.binding.ip + ':' +

inttostr(clientconnection.socket.binding.port);

end;

dsshowdataset['clientusername'] := dsconnecteventobject.connectproperties

[tdbxpropertynames.username];

dsshowdataset['clientuserpassword'] :=

dsconnecteventobject.connectproperties[tdbxpropertynames.password];

dsshowdataset['serverinfo'] := dsconnecteventobject.connectproperties

[tdbxpropertynames.serverconnection];

dsshowdataset.post;

end;

end;

得到伺服器的資料

要設定伺服器 isa防火牆設定問題。request.servervariables url 返回伺服器位址 request.servervariables path info 客戶端提供的路徑資訊 request.servervariables path translated 通過由虛擬至物理的對映...

Loadrunner得到伺服器引數

首先你得確定你所監視的伺服器與你的測試機是在同乙個區域網內,監控windows系統 1 監視連線前的準備工作 1 進入被監視windows系統,開啟以下二個服務remote procedure call rpc 和remote registry 開始 執行 中輸入services.msc,開啟對應服...

雲伺服器如何搭建 SVN 伺服器

svn是乙個版本控制系統,相對於的 rcs cvs 採用了分支管理系統,它的設計目標就是取代 cvs 一 安裝svn yum install y subversion 二 建立svn版本庫 建立專案版本庫 mkdir p data svn myproject svnadmin create data...