20#include <idfxx/net/endpoint>
21#include <idfxx/net/error>
22#include <idfxx/net/netconn/buffer>
84#ifdef CONFIG_COMPILER_CXX_EXCEPTIONS
101#ifdef CONFIG_COMPILER_CXX_EXCEPTIONS
123#ifdef CONFIG_COMPILER_CXX_EXCEPTIONS
143#ifdef CONFIG_COMPILER_CXX_EXCEPTIONS
160#ifdef CONFIG_COMPILER_CXX_EXCEPTIONS
177#ifdef CONFIG_COMPILER_CXX_EXCEPTIONS
209#ifdef CONFIG_COMPILER_CXX_EXCEPTIONS
260#ifdef CONFIG_COMPILER_CXX_EXCEPTIONS
307#ifdef CONFIG_COMPILER_CXX_EXCEPTIONS
330#ifdef CONFIG_COMPILER_CXX_EXCEPTIONS
359#ifdef CONFIG_COMPILER_CXX_EXCEPTIONS
382 : base_channel(conn,
fam) {}
397 size_t _pending_offset = 0;
Type-safe set of flags from a scoped enum.
Address/port pair identifying a transport endpoint.
Owning handle for a netconn buffer.
result< void > try_close()
Closes the netconn.
size_t send(std::span< const std::byte > data, idfxx::flags< write_flag > flags={})
Sends a buffer on the TCP netconn.
void close()
Closes the netconn.
void shutdown(direction dir)
Shuts down one direction on the netconn (half-close).
buffer recv()
Receives the next buffer from the connection.
stream_channel(address_family fam)
Creates a TCP netconn for the given address family.
result< void > try_shutdown()
Shuts down both directions on the netconn.
result< endpoint > try_peer_endpoint() const
Returns the remote endpoint the channel is connected to.
result< buffer > try_recv()
Receives the next buffer from the connection.
std::span< std::byte > recv(std::span< std::byte > buf)
Receives data into a caller-provided buffer.
result< void > try_connect(const endpoint &peer)
Connects to the given remote endpoint.
result< std::span< std::byte > > try_recv(std::span< std::byte > buf)
Receives data into a caller-provided buffer.
result< void > try_shutdown(direction dir)
Shuts down one direction on the netconn (half-close).
static result< stream_channel > make()
Creates a TCP netconn with default address family (IPv4).
void shutdown()
Shuts down both directions on the netconn.
size_t send(std::string_view data, idfxx::flags< write_flag > flags={})
Sends a string view on the TCP netconn.
static result< stream_channel > make(address_family fam)
Creates a TCP netconn for the given address family.
void connect(const endpoint &peer)
Connects to the given remote endpoint.
result< size_t > try_send(std::string_view data, idfxx::flags< write_flag > flags={})
Sends a string view on the TCP netconn.
endpoint peer_endpoint() const
Returns the remote endpoint the channel is connected to.
stream_channel()
Creates a TCP netconn with default address family (IPv4).
result< size_t > try_send(std::span< const std::byte > data, idfxx::flags< write_flag > flags={})
Sends a buffer on the TCP netconn.
write_flag
Flags accepted by stream_channel::send / try_send.
@ dont_block
Return immediately rather than waiting for buffer space.
@ no_copy
Zero-copy: reference the caller's buffer rather than copying it.
@ more
Suppress the TCP PSH flag (allow more data to be coalesced).
address_family
Address family.
direction
One direction of a bidirectional transport.
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.