找回密码
 用户注册

QQ登录

只需一步,快速开始

查看: 4228|回复: 3

ace_asynch_connector的一个问题

[复制链接]
发表于 2009-10-21 16:41:55 | 显示全部楼层 |阅读模式
请问如果服务器没开,ace_asynch_connector在connect失败后,在哪里能获取失败信息?
发表于 2009-10-21 23:46:03 | 显示全部楼层
会有返回结果的,会自动回调:
template<class HANDLER>  
int ACE_Asynch_Connector< HANDLER >::validate_connection  (  const ACE_Asynch_Connect::Result &  result,  
  const ACE_INET_Addr &  remote,  
  const ACE_INET_Addr &  local
)  [virtual]

   Template method to validate peer before service is opened. This method is called when the connection attempt completes, whether it succeeded or failed, if the validate_connection argument to open() was non-zero or the validate_new_connection() method is called to turn this feature on. The default implementation returns 0. Users can (and probably should) reimplement this method to learn about the success or failure of the connection attempt. If the connection completed successfully, this method can be used to perform validation of the peer using it's address, running an authentication procedure (such as SSL) or anything else necessary or desireable. The return value from this method determines whether or not ACE will continue opening the service or abort the connection.


Parameters:
result  Result of the connection acceptance. Use result.success() to determine success or failure of the connection attempt.  
remote  Peer's address. If the connection failed, this object is undefined.  
local  Local address connection was completed from. If the connection failed, this object is undefined.

Return values:
-1  ACE_Asynch_Connector will close the connection, and the service will not be opened.  
0  Service opening will proceeed.  

Returns:
Return value is ignored if the connection attempt failed.
发表于 2009-10-22 16:16:10 | 显示全部楼层
原帖由 winston 于 2009-10-21 23:46 发表
Users can (and probably should) reimplement this method to learn about the success or failure of the connection attempt.

看来一般是要自己实现了。
打出错信息unix下常用perror(),window下不太熟悉。ACE应该有类似perror()之类的封装函数吧。
发表于 2009-10-27 16:37:55 | 显示全部楼层
原帖由 wishel 于 2009-10-22 16:16 发表


看来一般是要自己实现了。
打出错信息unix下常用perror(),window下不太熟悉。ACE应该有类似perror()之类的封装函数吧。

ACE_OS::perror();
但是不全,只能打印clib有关的。系统api相关的还是要查文档。
您需要登录后才可以回帖 登录 | 用户注册

本版积分规则

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

GMT+8, 2024-11-22 18:05 , Processed in 0.019938 second(s), 5 queries , Redis On.

Powered by Discuz! X3.5

© 2001-2023 Discuz! Team.

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