boost::asio::ip::tcp::socket(io_context));
boost::shared_ptr<boost::asio::ip::tcp::resolver> resolver_ptr(new boost::asio::ip::tcp::resolver(io_context));
boost::shared_ptr<boost::asio::ip::tcp::resolver::query> query_ptr(new boost::asio::ip::tcp::resolver::query("127.0.0.1", "1212"));
Connection connection(socket_ptr, resolver_ptr, query_ptr);
}
class Connection{
public:
Connection(boost::shared_ptr<boost::asio::ip::tcp::socket> socket, boost::shared_ptr<boost::asio::ip::tcp::resolver> resolver, boost::shared_ptr<boost::asio::ip::tcp::resolver::query> query) : socket(socket), resolver(resolver), query(query){}
protected:
boost::shared_ptr<boost::asio::ip::tcp::socket> socket;
boost::shared_ptr<boost::asio::ip::tcp::resolver> resolver;
boost::shared_ptr<boost::asio::ip::tcp::resolver::query> query;
static void onConnect(const boost::system::error_code& ec, const boost::asio::ip::tcp::endpoint& endpoint) ;
void resolve_handler(const boost::system::error_code& ec, boost::asio::ip::tcp::resolver::results_type results);
};
terminate called after throwing an instance of 'boost::wrapexcept<boost::system::system_error>'
what(): bind: Address already in use [system:98 at /usr/include/boost/asio/detail/reactive_socket_service.hpp:161 in function 'bind']
Аварийный останов
Почему оно так делается?
Оберните код в теги: 3 символа ` до и после кода (в случае одиночной конструкции достаточно 1 ` с обеих сторон). Спасибо!
Обсуждают сегодня