找回密码
 用户注册

QQ登录

只需一步,快速开始

查看: 4940|回复: 3

Proactor模式的ACE_Service_Handler中如何得到对方IP

[复制链接]
发表于 2009-7-12 10:21:46 | 显示全部楼层 |阅读模式
我需要在ACE_Service_Handler的open函数(virtual void open(ACE_HANDLE h, ACE_Message_Block& mb))中得到对方IP,即如何通过已知的socket连接句柄(ACE_HANDLE h)得到对方的IP?
发表于 2009-7-12 17:04:40 | 显示全部楼层
不同的os有不同的api,这个跟ace无关
发表于 2009-7-12 18:48:24 | 显示全部楼层
看一下ACE_Service_Handle的address挂钩方法,重载即可
发表于 2009-7-12 22:18:12 | 显示全部楼层
Each networked application service class in the ACE Proactor framework derives from ACE_Service_Handler. Its key methods are shown in the following table:

Method
Description

open()
Hook method called to initialize the service after establishing a new connection

addresses()
Hook method to capture the local and remote addresses for the service connection



As mentioned above, ACE_Asynch_Acceptor and ACE_Asynch_Connector both call the ACE_Service_Handler::open() hook method for each new connection established. The handle argument is the handle for the connected socket. The ACE_Message_Block argument may contain data from the peer if the bytes_to_read parameter to ACE_Asynch_Acceptor::open() was greater than 0. Since this Windows-specific facility is often used with non-IP protocols (e.g., X.25), we don't discuss its use here. The ACE Proactor framework manages the ACE_Message_Block, so the service need not be concerned with it.

If the service handler requires either the local or peer addresses on the new connection, it must implement the addresses() hook method to capture them when the connection is established. The ACE Proactor framework calls this method if the pass_address argument to the asynchronous connection factory was 1. This method is more significant on Windows because the connection addresses cannot be obtained any other way when asynchronous connection establishment is used.
您需要登录后才可以回帖 登录 | 用户注册

本版积分规则

Archiver|手机版|小黑屋|ACE Developer ( 京ICP备06055248号 )

GMT+8, 2024-12-23 17:31 , Processed in 0.020087 second(s), 6 queries , Redis On.

Powered by Discuz! X3.5

© 2001-2023 Discuz! Team.

快速回复 返回顶部 返回列表