28#include <idfxx/net/endpoint>
29#include <idfxx/net/error>
46 std::optional<address_family>
family = std::nullopt;
58 std::optional<ip_protocol>
protocol = std::nullopt;
70 std::string_view host,
73 bool (*sink)(
void* ctx,
const endpoint&),
77 std::string_view host,
78 std::string_view service,
80 bool (*sink)(
void* ctx,
const endpoint&),
85bool invoke_resolve_sink(
void* ctx,
const endpoint& ep) {
86 F& fn = *
static_cast<F*
>(ctx);
87 if constexpr (std::is_void_v<std::invoke_result_t<F&, const endpoint&>>) {
98#ifdef CONFIG_COMPILER_CXX_EXCEPTIONS
125#ifdef CONFIG_COMPILER_CXX_EXCEPTIONS
152#ifdef CONFIG_COMPILER_CXX_EXCEPTIONS
196[[nodiscard]] result<void>
198 using fn_type = std::remove_reference_t<F>;
199 return detail::resolve_for_each(host, port, opts, &detail::invoke_resolve_sink<fn_type>, std::addressof(f));
202#ifdef CONFIG_COMPILER_CXX_EXCEPTIONS
240[[nodiscard]] result<void>
242 using fn_type = std::remove_reference_t<F>;
243 return detail::resolve_for_each(host, service, opts, &detail::invoke_resolve_sink<fn_type>, std::addressof(f));
246#ifdef CONFIG_COMPILER_CXX_EXCEPTIONS
281#ifdef CONFIG_COMPILER_CXX_EXCEPTIONS
298[[nodiscard]] std::vector<endpoint>
Address/port pair identifying a transport endpoint.
std::vector< endpoint > resolve(std::string_view host, port_number port, const resolver_options &opts={})
Resolves a host and numeric port and collects every endpoint.
result< void > try_resolve_each(std::string_view host, port_number port, F &&f, const resolver_options &opts={})
Visits each resolved endpoint for a host and numeric port without allocating.
result< std::vector< endpoint > > try_resolve(std::string_view host, port_number port, const resolver_options &opts={})
Resolves a host and numeric port and collects every endpoint.
uint16_t port_number
Port number type for transport endpoints.
endpoint resolve_one(std::string_view host, port_number port, const resolver_options &opts={})
Resolves a host and numeric port and returns the first matching endpoint.
void resolve_each(std::string_view host, port_number port, F &&f, const resolver_options &opts={})
Visits each resolved endpoint for a host and numeric port without allocating.
result< endpoint > try_resolve_one(std::string_view host, port_number port, const resolver_options &opts={})
Resolves a host and numeric port and returns the first matching endpoint.
T unwrap(result< T > result)
Throws a std::system_error if the result is an error.
std::expected< T, std::error_code > result
result type wrapping a value or error code.
Resolver hints used by the resolution functions.
bool passive
Request results suitable for bind() rather than connect().
bool numeric_host
Require the host to be a numeric address — skip the DNS lookup.
std::optional< address_family > family
Address family preference.
std::optional< ip_protocol > protocol
Restrict results to a particular transport protocol.
bool numeric_port
Require the service to be a numeric port — skip the service-name lookup.