19#include <idfxx/net/endpoint>
20#include <idfxx/net/error>
26namespace idfxx::net::detail {
28class ip_io_socket_base :
public ip_socket_base {
30#ifdef CONFIG_COMPILER_CXX_EXCEPTIONS
37 [[nodiscard]] endpoint peer_endpoint()
const {
return idfxx::unwrap(try_peer_endpoint()); }
41 [[nodiscard]] result<endpoint> try_peer_endpoint()
const;
43#ifdef CONFIG_COMPILER_CXX_EXCEPTIONS
63 [[nodiscard]] result<void>
try_connect(
const endpoint& peer);
65#ifdef CONFIG_COMPILER_CXX_EXCEPTIONS
77 [[nodiscard]] std::span<std::byte> recv(std::span<std::byte> buf) {
return idfxx::unwrap(try_recv(buf)); }
86 [[nodiscard]] result<std::span<std::byte>> try_recv(std::span<std::byte> buf);
95 void set_send_buffer(
size_t bytes)
noexcept;
104 template<
typename Rep,
typename Period>
105 void set_send_timeout(
const std::chrono::duration<Rep, Period>& t)
noexcept {
106 _set_send_timeout(std::chrono::ceil<std::chrono::milliseconds>(t));
109#ifdef CONFIG_COMPILER_CXX_EXCEPTIONS
118 template<
typename Rep,
typename Period>
119 void wait_writable(
const std::chrono::duration<Rep, Period>& timeout) {
120 idfxx::unwrap(_try_wait_writable(std::chrono::ceil<std::chrono::milliseconds>(timeout)));
130 template<
typename Rep,
typename Period>
131 [[nodiscard]] result<void> try_wait_writable(
const std::chrono::duration<Rep, Period>& timeout) {
132 return _try_wait_writable(std::chrono::ceil<std::chrono::milliseconds>(timeout));
139 [[nodiscard]]
size_t get_send_buffer() const noexcept;
142 using ip_socket_base::ip_socket_base;
144 void _set_send_timeout(std::chrono::milliseconds t) noexcept;
145 [[nodiscard]] result<
void> _try_wait_writable(std::chrono::milliseconds timeout);
void connect()
Connects to the configured access point.
result< void > try_connect()
Connects to the configured access point.
T unwrap(result< T > result)
Throws a std::system_error if the result is an error.