Determing client's IP
2018-06-17 18:57:20来源:未知 阅读 ()
Author | Determing client's IP |
Анатоли& 23.04.2009 18:39:46
Registered user |
How to determine client's IP address in THTTPServer.OnClientConnected, THTTPServer.OnClientDisonnected and TRtcFunction.OnExecute events?
|
Danijel Tkalcec [RTC] 23.04.2009 19:45:05
Registered user |
You get the "Sender:TRtcConnection" parameter in every event, which has the PeerAddr property (contains clients IP address).
There is even more information about the client available through the "Sender" parameter (which you get in every event triggered on the Server), you just need to typecast the variable to "TRtcDataServer" (as shown in Quick Start examples). For a complete list of methods and properties available through the "Sender" parameter received in every event on the RTC Server, check the following Help topics: TRtcConnection (master class) TRtcServer (extends TRtcConnection) TRtcDataServer (extends TRtcServer) TRtcHttpServer, TRtcISAPIServer and TRtcMessageServer components all extend TRtcDataServer. Best Regards, Danijel Tkalec |
Анатоли& 23.04.2009 20:55:24
Registered user |
A little bit strange behavior...
I have checked this property before ask you :-) But only in THTTPServer.OnClientConnected event. And it's always return '0.0.0.0' (when client works on localhost and when client works in network). But inside TRtcFunction.OnExecute event handler property PeerAddr returns valid IP address. |
Danijel Tkalcec [RTC] 23.04.2009 22:42:27
Registered user |
Sorry, I've missed to mention one important fact.
You should use the "OnConnect" and "OnDisconnect" events instead of the "OnClientConnect" and "OnClientDisconnect" events to monitor successful connections. The "OnClientConnect", "OnConnecting", "OnClientDisconnect" and "OnDisconnecting" events are there for notification purposes only and will not give you access to all connection parameters. To be more precise, the RealThinClient SDK has 3 events which can be triggered in the connect process: "OnClientConnect", "OnConnecting" and "OnConnect". The "OnClientConnect" event (which you have probably meant with "OnClientConnected") is the first event to be triggered when the Server is notified about a new client connection arriving, but *before* a connection has successfully been established and before a connection is ready for use. The same goes for the OnConnecting event. Since the connection is not fully established yet, you will NOT have access to all connection parameters from the "OnClientConnect" and "OnConnecting" events (for example, the "PeerAddr" and "PeerPort" properties are still undefined), and there is no guarantee the connection will really be established. The OnClientConnect event could actually be immediately followed by the OnClientDisconnect event without the connection ever having been fully established. On the other hand, the "OnConnect" event is fired only after the connection has successfully been established and when the connection is ready for use. Starting from this event onward, your Server can communicate with the Client (send and receive data). From the "OnConnect" event, you will have access to the clients IP address (through the PeerAddr property). Also note that the OnClientConnect, OnConnecting, OnClientDisconnect and OnDisconnecting events will not necessarily be triggered by all low-level connection providers (all APIs), but the OnConnect and OnDisconnect events will. Best Regards, Danijel Tkalcec |
标签:
版权申明:本站文章部分自网络,如有侵权,请联系:west999com@outlook.com
特别注意:本站所有转载文章言论不代表本站观点,本站所提供的摄影照片,插画,设计作品,如需使用,请与原作者联系,版权归原作者所有
- uniGUI之自定义JS事件动作ClientEvents(30) 2020-02-19
- Delphi 10.3.3 THTTPClient Post问题 2020-01-03
- Delphi XE 10.2.3使用CEF4Delphi取网页元素时碰到&n 2018-12-09
- TClientDataSet 提交时提示 Field value Required 但是未提 2018-12-06
- Delphi 10.3 Rio + iOS 12.1 SDK 编译错误 "libcha 2018-11-29
IDC资讯: 主机资讯 注册资讯 托管资讯 vps资讯 网站建设
网站运营: 建站经验 策划盈利 搜索优化 网站推广 免费资源
网络编程: Asp.Net编程 Asp编程 Php编程 Xml编程 Access Mssql Mysql 其它
服务器技术: Web服务器 Ftp服务器 Mail服务器 Dns服务器 安全防护
软件技巧: 其它软件 Word Excel Powerpoint Ghost Vista QQ空间 QQ FlashGet 迅雷
网页制作: FrontPages Dreamweaver Javascript css photoshop fireworks Flash