message_server::message_server(boost::asio::io_service& service, int const port_number, std::ostream& log) : log{log} , listener{service, boost::asio::ip::tcp::endpoint{boost::asio::ip::tcp::v4(), static_cast<unsigned short>(port_number)}} { start_accepting_connections(); }
void server:: start_async_helper ( ) { try { start_accepting_connections(); } catch (std::exception& e) { sdlog << LERROR << e.what(); } }
void server:: start ( ) { // make sure requires clause is not broken DLIB_CASSERT( this->is_running() == false, "\tvoid server::start" << "\n\tis_running() == " << this->is_running() << "\n\tthis: " << this ); start_accepting_connections(); }
void message_server::start_accepting_connections() { auto& connection = create_new_connection(); listener.async_accept(connection.get_socket(), [this, &connection] (boost::system::error_code const& e) { if (!e) { auto processor = get_message_processor_for_connection(connection); connection.start_reading_messages(std::move(processor)); } start_accepting_connections(); }); }