2014-12-02 64 views
0

错误时async_connect之称,是加速在Windows ASIO插座不能async_connect

uncaught exception of type N5boost16exception_detail10clone_implINS0_19error_info_injectorINS_6system12system_errorEEEEE 
- socket_select_interrupter: The attempted operation is not supported for the type of object referenced 

Demangled:

uncaught exception of type boost::exception_detail::clone_impl<boost::exception_detail::error_info_injector<boost::system::system_error> > - socket_select_interrupter: The attempted operation is not supported for the type of object referenced

下面是一些相关的代码:

typedef boost::shared_ptr<boost::asio::ip::tcp::socket> tTCPSocketPtr; 

boost::shared_ptr<boost::asio::io_service> ioService = boost::shared_ptr<boost::asio::io_service> (new boost::asio::io_service()); 

socketPtr = tTCPSocketPtr(new boost::asio::ip::tcp::socket(*ioService)); 

boost::asio::ip::tcp::endpoint endpoint(boost::asio::ip::address::from_string(this->ipAddress), this->port); 


// Set a deadline for the connect operation. 
deadline->expires_from_now(boost::posix_time::seconds(5)); 

socketPtr->async_connect(endpoint, 
     boost::bind(&AConnection::handle_connect, 
     shared_from_this(), _1, endpoint)); //errors out here 

我已经使用Google搜索并没有发现任何有用的东西。

我该如何解决这个错误? 谢谢, sb

+0

它不会出错'错误在这里'为简单异步操作不以内联方式执行的原因。所以你可能意思是说,如果你在那之前停下来(或者注释掉),你不会得到同样的错误? – sehe 2014-12-02 18:36:22

回答

2

你没有显示足够的代码。

但是,我可以用我的水晶球得到Win32错误代码,这可能意味着你使用的是无效句柄。

看到你使用enable_shared_from_this,我可以猜测这有助于你的问题(尽管它在代码中未显示)。

我最好的猜测是你可能会在构造函数中使用shared_from_this(这会导致错误)。

+0

谢谢你sehe。对async_connect的调用不在构造函数内。感谢您的意见。 – user2192008 2014-12-02 19:26:01

1

在Windows上,异步连接最终将调用ConnectEx(),这在Windows Vista之前的操作系统上不受支持。

因此,最重要的问题,恕我直言,你试图运行的代码是什么操作系统?

鉴于您在ConnectEx支持的操作系统上运行,下一个检查是您没有安装任何可能阻止ConnectEx被使用的LSP。 (可能最简单的方法来检查这是简单地运行代码在一个干净的安装虚拟机的操作系统有问题)...

+0

谢谢,Len。我在Windows 7 – user2192008 2014-12-02 19:50:49

+0

LSPs呢? – 2014-12-02 22:00:23

+0

感谢Len,我正在研究你的VM clean安装想法 – user2192008 2014-12-03 21:16:14