5#include <boost/asio/io_context.hpp>
6#include <boost/asio/ip/basic_resolver.hpp>
7#include <boost/asio/ip/tcp.hpp>
11inline bool resolve_sync_v4(std::string& host, std::string_view port)
15 boost::asio::io_context io_service;
17 boost::asio::ip::tcp::resolver resolver(io_service);
18 auto results = resolver.resolve(
19 boost::asio::ip::tcp::v4(), host, port,
20 boost::asio::ip::resolver_base::numeric_service);
22 for(
auto& result : results)
24 if(result.endpoint().address().is_loopback())
29 else if(result.endpoint().address().is_v4())
31 host = result.endpoint().address().to_string();
36 catch(
const std::exception& e)
38 ossia::logger().error(
"Could not resolve host: {} => {}", host, e.what());
spdlog::logger & logger() noexcept
Where the errors will be logged. Default is stderr.
Definition context.cpp:118