Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 9 additions & 6 deletions src/roar/server.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -109,8 +109,9 @@ namespace Roar
//------------------------------------------------------------------------------------------------------------------
boost::leaf::result<void> Server::start(unsigned short port, std::string const& host)
{
return start(Dns::resolveSingle(
impl_->acceptor.get_executor(), host, port, false, boost::asio::ip::resolver_base::flags::passive));
return start(
Dns::resolveSingle(
impl_->acceptor.get_executor(), host, port, false, boost::asio::ip::resolver_base::flags::passive));
}
//------------------------------------------------------------------------------------------------------------------
boost::asio::ip::basic_endpoint<boost::asio::ip::tcp> const& Server::getLocalEndpoint() const
Expand All @@ -120,25 +121,27 @@ namespace Roar
//------------------------------------------------------------------------------------------------------------------
boost::leaf::result<void> Server::start(boost::asio::ip::tcp::endpoint const& bindEndpoint)
{
using namespace std::string_literals;

stop();
boost::system::error_code ec;
impl_->bindEndpoint = bindEndpoint;

impl_->acceptor.open(impl_->bindEndpoint.protocol(), ec);
if (ec)
return boost::leaf::new_error("Could not open http server acceptor.", ec);
return boost::leaf::new_error("Could not open http server acceptor."s, ec);

impl_->acceptor.set_option(boost::asio::socket_base::reuse_address(true), ec);
if (ec)
return boost::leaf::new_error("Could not configure socket to reuse address.", ec);
return boost::leaf::new_error("Could not configure socket to reuse address."s, ec);

impl_->acceptor.bind(impl_->bindEndpoint, ec);
if (ec)
return boost::leaf::new_error("Could not bind socket.", ec);
return boost::leaf::new_error("Could not bind socket."s, ec);

impl_->acceptor.listen(boost::asio::socket_base::max_listen_connections, ec);
if (ec)
return boost::leaf::new_error("Could not listen on socket.", ec);
return boost::leaf::new_error("Could not listen on socket."s, ec);

impl_->resolvedEndpoint = impl_->acceptor.local_endpoint();
impl_->acceptOnce(0);
Expand Down
Loading