[英]Error with lib boost asio 1.47.0 in file basic_socket.hpp
i have an error in the following code when i tried to compile this: 我尝试编译时,在以下代码中有错误:
void Server::accept(void)
{
Network::ptr connection = Network::initialize(this->my_acceptor.get_io_service());
this->my_acceptor.async_accept(connection->socket(), bind(&Server::endCmd, this, *connection, placeholders::error));
}
void Server::endCmd(Network connection, const boost::system::error_code& error)
{
if (!error)
{
std::cout << "success!" << std::endl;
connection.start();
this->accept();
}
}
VC++ 2010 tell me the following error : VC ++ 2010告诉我以下错误:
Error 1 error C2248: 'boost::asio::basic_io_object<IoObjectService>::basic_io_object' : cannot access private member declared in class 'boost::asio::basic_io_object<IoObjectService>'
i know this error come to this line because when i comment it, the error disapear... After some research, it's probably with the socket's class when i call connection->getSocket()
but this function returns a ref to an instance of socket : 我知道这个错误来到这一行,因为当我评论它,错误消失...经过一些研究,它可能与套接字的类,当我调用
connection->getSocket()
但这个函数返回一个ref实例的套接字:
tcp::socket& Network::socket(void)
{
return (this->my_socket);
}
so i didn't find any solution on the web :( 所以我没有在网上找到任何解决方案:(
Anyone have an idea plz ? 有人有想法吗?
I had that problem too, and i spend a few hours to see what happened. 我也有这个问题,我花了几个小时看看发生了什么。 My case was:
我的情况是:
Original code in the B class was: B类中的原始代码是:
std::bind(&A::a_member, a_instance)
The problem was fixed (and of course) by using the address of the a_instance: 通过使用a_instance的地址修复了问题(当然):
std::bind(&A::a_member, &a_instance).
I did not notice that, and I took me a while to resolve this. 我没注意到,我花了一些时间来解决这个问题。 I hope that it will be help others too.
我希望它也会帮助别人。
Is async_accept something you wrote yourself? 是async_accept你自己写的东西吗? If so, make sure it takes a REFERENCE to socket, and not pass by value.
如果是这样,请确保它对socket进行REFERENCE,而不是按值传递。 The error you're getting is saying that you're trying to copy construct, and the copy constructor is declared private (this is a the C++ way of enforcing that the class doesn't support copying).
您得到的错误是说您正在尝试复制构造,并且复制构造函数被声明为私有(这是C ++强制该类不支持复制的方式)。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.