boost::corosio::native_udp_socket
An asynchronous UDP socket with devirtualized I/O operations.
Synopsis
template<auto Backend>
class native_udp_socket
: public udp_socket
Description
This class template inherits from udp_socket and shadows the async operations (send_to, recv_from, connect, send, recv) with versions that call the backend implementation directly, allowing the compiler to inline through the entire call chain.
Non‐async operations (open, close, cancel, bind, socket options) remain unchanged and dispatch through the compiled library.
A native_udp_socket IS‐A udp_socket and can be passed to any function expecting udp_socket&, in which case virtual dispatch is used transparently.
Thread Safety
Same as udp_socket.
Example
#include <boost/corosio/native/native_udp_socket.hpp>
native_io_context<epoll> ctx;
native_udp_socket<epoll> s(ctx);
s.open();
s.bind(endpoint(ipv4_address::any(), 9000));
char buf[1024];
endpoint sender;
auto [ec, n] = co_await s.recv_from(
capy::mutable_buffer(buf, sizeof(buf)), sender);
Types
Name |
Description |
Represent the awaitable returned by |
|
RAII wrapper for I/O object implementation lifetime. |
|
Define backend hooks for UDP socket operations. |
|
Service interface for I/O object lifecycle management. |
|
Represent the awaitable returned by |
|
Represent the awaitable returned by |
|
Represent the awaitable returned by |
|
Represent the awaitable returned by |
|
Represent the awaitable returned by |
Member Functions
Name |
Description |
|
Constructors |
|
Assignment operators |
Bind the socket to a local endpoint. |
|
Cancel any pending asynchronous operations. |
|
Close the socket. |
|
Asynchronously connect to set the default peer. |
|
Return the execution context. |
|
Get a socket option. |
|
Check if the socket is open. |
|
Get the local endpoint of the socket. |
|
Get the native socket handle. |
|
Open the socket. |
|
Receive a datagram from the connected peer. |
|
Receive a datagram and capture the sender's endpoint. |
|
Get the remote endpoint of the socket. |
|
Send a datagram to the connected peer. |
|
Send a datagram to the specified destination. |
|
Set a socket option. |
|
Asynchronously wait for the socket to be ready. |
Protected Member Functions
Name |
Description |
|
Move assign from another I/O object. |
Protected Static Member Functions
Name |
Description |
Create a handle bound to a service found in the context. |
Template Parameters
Name |
Description |
Backend |
A backend tag value (e.g., |
See Also
udp_socket, epoll_t
Created with MrDocs