matt 发表于 2009-10-21 16:41:55

ace_asynch_connector的一个问题

请问如果服务器没开,ace_asynch_connector在connect失败后,在哪里能获取失败信息?

winston 发表于 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
)

   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:
resultResult of the connection acceptance. Use result.success() to determine success or failure of the connection attempt.
remotePeer's address. If the connection failed, this object is undefined.
localLocal address connection was completed from. If the connection failed, this object is undefined.

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

Returns:
Return value is ignored if the connection attempt failed.

wishel 发表于 2009-10-22 16:16:10

原帖由 winston 于 2009-10-21 23:46 发表 http://www.acejoy.com/bbs/images/common/back.gif
Users can (and probably should) reimplement this method to learn about the success or failure of the connection attempt.

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

wishel 发表于 2009-10-27 16:37:55

原帖由 wishel 于 2009-10-22 16:16 发表 http://www.acejoy.com/bbs/images/common/back.gif


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

ACE_OS::perror();
但是不全,只能打印clib有关的。系统api相关的还是要查文档。
页: [1]
查看完整版本: ace_asynch_connector的一个问题