Throw error if server bind or listen fails (#309)

* Throw error if server bind or listen fails
This commit is contained in:
CJ Cobb
2022-09-29 16:07:33 -04:00
committed by GitHub
parent ccf73dc68c
commit db2b9dac3b

View File

@@ -240,12 +240,22 @@ public:
// Bind to the server address
acceptor_.bind(endpoint, ec);
if (ec)
return;
{
BOOST_LOG_TRIVIAL(error)
<< "Failed to bind to endpoint: " << endpoint
<< ". message: " << ec.message();
throw std::runtime_error("Failed to bind to specified endpoint");
}
// Start listening for connections
acceptor_.listen(net::socket_base::max_listen_connections, ec);
if (ec)
return;
{
BOOST_LOG_TRIVIAL(error)
<< "Failed to listen at endpoint: " << endpoint
<< ". message: " << ec.message();
throw std::runtime_error("Failed to listen at specified endpoint");
}
}
// Start accepting incoming connections