mirror of
https://github.com/XRPLF/clio.git
synced 2026-07-26 00:20:34 +00:00
Create generate free port class to avoid conflicting ports (#1439)
Fixes #1317
This commit is contained in:
@@ -105,9 +105,9 @@ doSession(
|
||||
|
||||
} // namespace
|
||||
|
||||
TestHttpServer::TestHttpServer(boost::asio::io_context& context, std::string host, int const port) : acceptor_(context)
|
||||
TestHttpServer::TestHttpServer(boost::asio::io_context& context, std::string host) : acceptor_(context)
|
||||
{
|
||||
boost::asio::ip::tcp::endpoint const endpoint(boost::asio::ip::make_address(host), port);
|
||||
boost::asio::ip::tcp::endpoint const endpoint(boost::asio::ip::make_address(host), 0);
|
||||
acceptor_.open(endpoint.protocol());
|
||||
acceptor_.set_option(asio::socket_base::reuse_address(true));
|
||||
acceptor_.bind(endpoint);
|
||||
@@ -134,3 +134,9 @@ TestHttpServer::handleRequest(TestHttpServer::RequestHandler handler, bool const
|
||||
boost::asio::detached
|
||||
);
|
||||
}
|
||||
|
||||
std::string
|
||||
TestHttpServer::port() const
|
||||
{
|
||||
return std::to_string(acceptor_.local_endpoint().port());
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user