25#include <idfxx/net/endpoint>
26#include <idfxx/net/error>
34namespace idfxx::net::detail {
39 ~ip_socket_base() noexcept;
41 ip_socket_base(const ip_socket_base&) = delete;
42 ip_socket_base& operator=(const ip_socket_base&) = delete;
44 ip_socket_base(ip_socket_base&& other) noexcept;
45 ip_socket_base& operator=(ip_socket_base&& other) noexcept;
54 [[nodiscard]]
int idf_handle() const noexcept {
return _fd; }
60 [[nodiscard]]
bool is_open() const noexcept {
return _fd >= 0; }
63 void close() noexcept;
71 [[nodiscard]] std::optional<endpoint> local_endpoint() const noexcept;
73#ifdef CONFIG_COMPILER_CXX_EXCEPTIONS
83 void bind(
const endpoint& addr) {
idfxx::unwrap(try_bind(addr)); }
94 [[nodiscard]] result<void> try_bind(
const endpoint& addr);
103 void set_non_blocking(
bool on)
noexcept;
112 void set_reuse_address(
bool on)
noexcept;
121 void set_recv_buffer(
size_t bytes)
noexcept;
129 void set_ttl(uint8_t ttl)
noexcept;
137 void set_tos(uint8_t tos)
noexcept;
148 void set_dscp(dscp value)
noexcept;
161 template<
typename Rep,
typename Period>
162 void set_recv_timeout(
const std::chrono::duration<Rep, Period>& t)
noexcept {
163 _set_recv_timeout(std::chrono::ceil<std::chrono::milliseconds>(t));
166#ifdef CONFIG_LWIP_IPV6
177 void set_ipv6_only(
bool on)
noexcept;
180#ifdef CONFIG_COMPILER_CXX_EXCEPTIONS
191 void set_bind_to_device(std::string_view ifname) {
idfxx::unwrap(try_set_bind_to_device(ifname)); }
203 [[nodiscard]] result<void> try_set_bind_to_device(std::string_view ifname);
205#ifdef CONFIG_COMPILER_CXX_EXCEPTIONS
214 template<
typename Rep,
typename Period>
215 void wait_readable(
const std::chrono::duration<Rep, Period>& timeout) {
216 idfxx::unwrap(_try_wait_readable(std::chrono::ceil<std::chrono::milliseconds>(timeout)));
226 template<
typename Rep,
typename Period>
227 [[nodiscard]] result<void> try_wait_readable(
const std::chrono::duration<Rep, Period>& timeout) {
228 return _try_wait_readable(std::chrono::ceil<std::chrono::milliseconds>(timeout));
235 [[nodiscard]]
size_t get_recv_buffer() const noexcept;
245 [[nodiscard]] std::error_code get_last_error() const noexcept;
257 [[nodiscard]]
int idf_last_error() const noexcept;
260 ip_socket_base() noexcept = default;
261 ip_socket_base(
int fd, address_family fam) noexcept
265 void _set_recv_timeout(std::chrono::milliseconds t)
noexcept;
266 [[nodiscard]] result<void> _try_wait_readable(std::chrono::milliseconds timeout);
family
DS18x20 device family identifiers.
address_family
Address family.
T unwrap(result< T > result)
Throws a std::system_error if the result is an error.