20#include <idfxx/net/endpoint>
21#include <idfxx/net/error>
71 bool non_blocking =
false;
74 std::optional<std::chrono::milliseconds> recv_timeout = std::nullopt;
77 std::optional<std::chrono::milliseconds> send_timeout = std::nullopt;
80 bool reuse_address =
false;
83 bool broadcast =
false;
84#ifdef CONFIG_LWIP_IPV6
91 std::optional<std::string_view> bind_to_device = std::nullopt;
96#ifdef CONFIG_COMPILER_CXX_EXCEPTIONS
113#ifdef CONFIG_COMPILER_CXX_EXCEPTIONS
133#ifdef CONFIG_COMPILER_CXX_EXCEPTIONS
155#ifdef CONFIG_COMPILER_CXX_EXCEPTIONS
191#ifdef CONFIG_COMPILER_CXX_EXCEPTIONS
220#ifdef CONFIG_COMPILER_CXX_EXCEPTIONS
266#ifdef CONFIG_COMPILER_CXX_EXCEPTIONS
299#ifdef CONFIG_LWIP_IPV6
302#ifdef CONFIG_COMPILER_CXX_EXCEPTIONS
332#ifdef CONFIG_COMPILER_CXX_EXCEPTIONS
360#ifdef CONFIG_COMPILER_CXX_EXCEPTIONS
392 [[nodiscard]] result<void> try_set_multicast_interface_v6(uint8_t if_index);
396 datagram_socket(
int fd, address_family fam) noexcept
397 : connectionless_socket_base(fd, fam) {}
void set_multicast_hops(uint8_t hops) noexcept
Sets the hop limit (IPv6) / TTL (IPv4) for outgoing multicast packets.
datagram_socket()
Creates a new UDP socket with default configuration (IPv4, blocking).
result< void > try_leave_multicast_v4(ipv4_addr group, ipv4_addr interface={})
Leaves an IPv4 multicast group.
result< void > try_join_multicast_v4(ipv4_addr group, ipv4_addr interface={})
Joins an IPv4 multicast group so that the socket receives datagrams sent to that group.
void set_multicast_interface_v4(ipv4_addr addr)
Selects the local interface used for outgoing IPv4 multicast.
static result< datagram_socket > make()
Creates a new UDP socket with default configuration (IPv4, blocking).
void leave_multicast_v4(ipv4_addr group, ipv4_addr interface={})
Leaves an IPv4 multicast group.
static result< datagram_socket > make(address_family fam)
Creates a new UDP socket of the given address family.
static result< datagram_socket > make(const config &cfg)
Creates a new UDP socket with the given configuration.
datagram_socket(address_family fam)
Creates a new UDP socket of the given address family.
void join_multicast_v4(ipv4_addr group, ipv4_addr interface={})
Joins an IPv4 multicast group so that the socket receives datagrams sent to that group.
void set_broadcast(bool on) noexcept
Toggles permission to send datagrams to broadcast addresses.
datagram_socket(const config &cfg)
Creates a new UDP socket with the given configuration.
void set_multicast_loopback(bool on) noexcept
Toggles whether outgoing multicast packets are also delivered to local sockets that have joined the g...
result< void > try_set_multicast_interface_v4(ipv4_addr addr)
Selects the local interface used for outgoing IPv4 multicast.
result< size_t > try_send(std::span< const std::byte > buf)
Sends a datagram on a connected socket (after try_connect).
size_t send(std::span< const std::byte > buf)
Sends a datagram on a connected socket (after connect).
address_family
Address family.
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.
Datagram socket configuration.