调用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
分解:
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
我用谷歌搜索过,没有发现任何有用的东西。
我该如何解决这个错误? 谢谢你, 某人
最佳答案
您没有显示足够的代码。
不过,使用我的 Crystal 球,我可以猜到您收到的是 Win32 错误代码,这可能意味着您使用的句柄无效。
看到您使用了 enable_shared_from_this
,我猜这会导致您的问题(尽管它在代码中未显示)。
我最好的猜测是您可能在构造函数内部使用 shared_from_this
(这会导致错误)。
关于c++ - Windows 上的 Boost asio 套接字无法异步连接,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27255882/