我在尝试编译以下代码时遇到了错误:
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告诉我以下错误:
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>'
我知道这个错误出现在这一行,因为当我注释掉它时,错误消失了... 经过一些研究,可能是与套接字类有关,当我调用connection->getSocket()
时,但这个函数返回一个套接字实例的引用:
tcp::socket& Network::socket(void)
{
return (this->my_socket);
}
我在网上没有找到任何解决方案 :(
请问有人有想法吗?