mirror of
https://github.com/XRPLF/clio.git
synced 2025-11-28 07:35:52 +00:00
Create generate free port class to avoid conflicting ports (#1439)
Fixes #1317
This commit is contained in:
@@ -105,14 +105,20 @@ TestWsConnection::headers() const
|
||||
return headers_;
|
||||
}
|
||||
|
||||
TestWsServer::TestWsServer(asio::io_context& context, std::string const& host, int port) : acceptor_(context)
|
||||
TestWsServer::TestWsServer(asio::io_context& context, std::string const& host) : acceptor_(context)
|
||||
{
|
||||
auto endpoint = asio::ip::tcp::endpoint(boost::asio::ip::make_address(host), port);
|
||||
auto endpoint = asio::ip::tcp::endpoint(boost::asio::ip::make_address(host), 0);
|
||||
acceptor_.open(endpoint.protocol());
|
||||
acceptor_.set_option(asio::socket_base::reuse_address(true));
|
||||
acceptor_.bind(endpoint);
|
||||
}
|
||||
|
||||
std::string
|
||||
TestWsServer::port() const
|
||||
{
|
||||
return std::to_string(this->acceptor_.local_endpoint().port());
|
||||
}
|
||||
|
||||
std::expected<TestWsConnection, util::requests::RequestError>
|
||||
TestWsServer::acceptConnection(asio::yield_context yield)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user