Determing client's IP

 

AuthorDeterming 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

转载于:https://www.cnblogs.com/liangchua/p/6594010.html

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.mzph.cn/news/371252.shtml

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

mysql aa复制_MySQL的复制架构与优化

MySQL的复制架构与优化###########原理###########1.主服务器将更新的数据的sql语句(例如,insert,update,delete等)写入到二进制文件中(由log-bin选项开启)。此二进制文件由一个索引文件跟踪维护。2.从服务器连接(使用I/O线程连接)主服务器&a…

如何安装Gradle

Gradle是一个简单而强大的构建工具。 它类似于Ant构建工具。 它可以很好地管理构建,还可以处理构建依赖性。 Gradle最好的部分是它是开源项目。 如果您正在考虑安装并尝试一下,那么您来对地方了。 Gradle的开发周期为4周,因此,每隔…

nmap使用指南

一、目标指定 1.CIDR标志位 192.168.1.0/24 2.指定范围 192.168.1.1-255 192.168.1-255.1&#xff08;任意位置&#xff09;3.IPv6地址只能用规范的IPv6地址或主机名指定。 CIDR 和八位字节范围不支持IPv6&#xff0c;因为它们对于IPv6几乎没什么用。 -iL <文件名> 主机名…

#Pragma Pack(n)与内存分配

#pragma pack(n) 解释一&#xff1a; 每个特定平台上的编译器都有自己的默认“对齐系数”(也叫对齐模数)。程序员可以通过预编译命令#pragma pack(n)&#xff0c;n1,2,4,8,16来改变这一系数&#xff0c;其中的n就是你要指定的“对齐系数”。 规则&#xff1a; 1、数据成员对齐规…

Java死了还是无敌?

作家艾萨克阿西莫夫&#xff08;Isaac Asimov&#xff09;曾经说过“唯一不变的就是变化”。 这不仅仅是软件行业中的一个短语&#xff0c;这是绝对的事实。 曾经有一天&#xff0c;Corba为王&#xff0c;但Web Services篡夺了它。 即使在Web服务领域&#xff0c;过去也全都是关…

mysql数据库访问问题吗_#MySQL数据库无法远程访问的问题

在 Ubuntu上装了mysql&#xff0c;因为项目的数据库是mysql&#xff0c;将项目放在tomcat里面webapp下面&#xff0c;一直启动不成功。本来一直以为是jdbc驱动问题&#xff0c;后来发现不是。1.cd /etc/mysql 找到my.cnf查找到bind-address&#xff0c;将 bind-address127.0.0.…

SolidEdge如何复制特征 建立类似于UG 块的概念

直接CtrlC和CtrlV可以实现特征的复制粘贴 按N键可以改变特征方向 已经复制完成的特征要进行定位&#xff0c;则右击该特征&#xff0c;编辑轮廓&#xff0c;可以进行聪慧尺寸的标注 使用特征库的方式&#xff0c;就像UG的块一样&#xff0c;可以给所有零件调用。在任意位置新建…

Gradle自定义插件

本教程介绍了创建Gradle独立自定义插件的方法。 它涵盖以下主题 创建任务&#xff0c;并在“自定义”插件中使用它 独立的自定义插件 简短的插件ID 使用settings.gradle自定义Gradle设置 项目信息&#xff1a; 摇篮版本&#xff1a;1.1 操作系统平台&#xff1a;Ubuntu 1…

mysql映射文件_Mybatis SQL映射文件

简单查询insert添加insert可以使用数据库支持的自动生成主键策略&#xff0c;设置useGeneratedKeys”true”&#xff0c;然后把keyProperty 设成对应的列&#xff0c;就搞定了。比如说上面的StudentEntity 使用auto-generated 为id 列生成主键.还可以使用selectKey元素。下面例…

监听微信、支付宝等移动app及浏览器的返回、后退、上一页按钮的事件方法

在实际的应用中&#xff0c;我们常常需要实现在移动app和浏览器中点击返回、后退、上一页等按钮实现自己的关闭页面、调整到指定页面或执行一些其它操作的 需求&#xff0c;那在代码中怎样监听当点击微信、支付宝、百度糯米、百度钱包等app的返回按钮或者浏览器的上一页或后退按…

第七天作业

---恢复内容开始--- 作业一&#xff1a;nginx服务 二进制安装nginx包 作为web服务修改配置文件 让配置生效&#xff0c;验证配置 直至出现epel的两个文件&#xff0c;否则reinstall, 接下来写配置文件&#xff0c; 这款软件的服务目录&#xff0c; 在里面编辑一些东西&#xff…

Java测试提示

介绍 我喜欢自动化测试。 在一次极少的转移到op-ed 1中&#xff0c;我想到了一些想法&#xff08;阅读–意见&#xff09;。 在开始如何最好地构成您的测试之前&#xff0c;我先简单问一下–测试的原因是什么&#xff1f; 大致来说&#xff0c;我认为它们是&#xff1a; 减少…

pdo mysql fedora_在Fedora 23 Server和Workstation上安装LAMP(Linux, Apache, MariaDB和PHP)

在安装LAMP之前&#xff0c;建议先更新系统包$ sudo dnf update第一步&#xff1a;安装Apache Web服务器1.在Fedora 23安装Apache&#xff0c;你可以运行下面的命令&#xff1a;$ sudo dnf install httpd2.安装完成后&#xff0c;我们设置在系统启动时自动启动Apache&#xff0…

洛谷P1937 [USACO10MAR]仓配置Barn Allocation

题目描述 Farmer John recently opened up a new barn and is now accepting stall allocation requests from the cows since some of the stalls have a better view of the pastures. The barn comprises N (1 < N < 100,000) stalls conveniently numbered 1..N; sta…

人脸数据库大全(包括人脸识别、关键点检测、表情识别,人脸姿态等等)

搞计算机视觉的人&#xff0c;对人脸技术并不陌生。在做实验的时候需要各种数据集进行训练&#xff0c;却往往苦于找不到合适的数据集&#xff0c;这篇文章将给大家带来一点福音。 目前为止最全的是人脸数据库总结&#xff1a; The Color FERET Database, USA The FERET progra…

JavaFX游戏(四连环)

这是我的第一个JavaFX游戏教程&#xff0c;也是我关于JavaFX面板的第一篇博客文章。 我仅用200几行代码就完成了这款四连环游戏&#xff0c;足以应付一个简单的游戏。 我在这里使用GridPane面板对磁盘进行布局&#xff0c;GridPane是JavaFX布局窗格之一&#xff0c;但它与另一个…

vs使用了未初始化的局部变量怎么解决_C程序为什么要初始化?

作者:守望,Linux应用开发者,目前在公众号【编程珠玑】 分享Linux/C/C++/数据结构与算法/工具等原创技术文章和学习资源。 前言 什么是初始化?为什么要初始化?静态变量和局部变量的初始化又有什么区别?实际应用中应该怎么做?本文将一一回答这些问题。 什么是初始化 初始化…

maven 配置 pom.xml 打包生成:单jar包/jar包+lib目录

http://www.jianshu.com/p/9146cec6cc60转载于:https://www.cnblogs.com/Baronboy/p/7510942.html

zabbix安装MySQL失败_MySQL数据库之zabbix3.x安装出现“configure: error: Not found mysqlclient library”的解决办法...

本文主要向大家介绍了MySQL数据库之zabbix3.x安装出现“configure: error: Not found mysqlclient library”的解决办法 &#xff0c;通过具体的内容向大家展现&#xff0c;希望对大家学习MySQL数据库有所帮助。如题所示&#xff0c;在CentOS6.x的系统中安装zabbix3.x&#xff…

拼图项目:延期的后果

Mark Reinhold先生于2012年7月宣布 &#xff0c;他们计划从Java 8撤回Jigsaw项目 &#xff0c;因为Jigsaw计划于2013年9月&#xff08;从现在开始一年&#xff09;推迟其发布。 这个日期是众所周知的&#xff0c;因为Oracle已决定实施Java的两年路线图计划&#xff0c;因此2013…