我不确定是什么导致了这个错误Already Open
#include "AsyncServer.h"
AsyncServer::AsyncServer(boost::asio::io_service& io_service, std::string ip, unsigned short port)
: acceptor(io_service, tcp::endpoint(boost::asio::ip::address_v4::from_string(ip), port))
{
BeginAccept();
}
AsyncServer::~AsyncServer()
{
}
void AsyncServer::BeginAccept(){
tcp::socket temp = tcp::socket(acceptor.get_io_service());
acceptor.async_accept(temp, boost::bind(&AsyncServer::EndAccept, this, boost::asio::placeholders::error));
}
void AsyncServer::EndAccept(const boost::system::error_code& error){
if (!error)
{
//continue with connection
std::cout << "connected" << std::endl;
}
else
{
std::cout << error.message() <<std::endl;
}
BeginAccept();
}
我想要做的是将套接字和错误传递给EndAccept
但它中断并且错误是Already Open
,我不知道这里有什么问题!