boost::corosio::native_local_datagram_socket

An asynchronous Unix datagram socket with devirtualized I/O.

Synopsis

template<auto Backend>
class native_local_datagram_socket
    : public local_datagram_socket

Description

This class template inherits from local_datagram_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_local_datagram_socket IS‐A local_datagram_socket and can be passed to any function expecting local_datagram_socket&, in which case virtual dispatch is used transparently.

Thread Safety

Example

#include <boost/corosio/native/native_local_datagram_socket.hpp>

native_io_context<epoll> ctx;
native_local_datagram_socket<epoll> s(ctx);
s.open();
s.bind(local_endpoint("/tmp/recv.sock"));
char buf[1024];
local_endpoint sender;
auto [ec, n] = co_await s.recv_from(
    capy::mutable_buffer(buf, sizeof(buf)), sender);

Base Classes

Name

Description

local_datagram_socket

An asynchronous Unix datagram socket for coroutine I/O.

Types

Name

Description

connect_awaitable

Represent the awaitable returned by connect.

handle

RAII wrapper for I/O object implementation lifetime.

implementation

Define backend hooks for local datagram socket operations.

io_service

Service interface for I/O object lifecycle management.

recv_awaitable

Represent the awaitable returned by recv.

recv_from_awaitable

Represent the awaitable returned by recv_from.

send_awaitable

Represent the awaitable returned by send.

send_to_awaitable

Represent the awaitable returned by send_to.

wait_awaitable

Represent the awaitable returned by wait.

Type Aliases

Name

Description

shutdown_type

The shutdown direction type used by shutdown().

Member Functions

Name

Description

native_local_datagram_socket [constructor] [deleted]

Constructors

operator= [deleted]

Assignment operators

assign

Assign an existing file descriptor to this socket.

available

Query the number of bytes available for reading.

bind

Bind the socket to a local endpoint.

cancel

Cancel any pending asynchronous operations.

close

Close the socket.

connect

Asynchronously connect to set the default peer.

context

Return the execution context.

get_option

Get a socket option.

is_open

Check if the socket is open.

local_endpoint

Get the local endpoint of the socket.

native_handle

Get the native socket handle.

open

Open the socket.

recv

Receive a datagram from the connected peer.

recv_from

Receive a datagram and capture the sender's endpoint.

release

Release ownership of the native socket handle.

remote_endpoint

Get the remote endpoint of the socket.

send

Send a datagram to the connected peer.

send_to

Send a datagram to the specified destination.

set_option

Set a socket option.

shutdown

shutdown overloads

wait

Asynchronously wait for the socket to be ready.

Protected Member Functions

Name

Description

operator= [deleted]

Move assign from another I/O object.

Protected Static Member Functions

Name

Description

create_handle

Create a handle bound to a service found in the context.

Protected Data Members

Name

Description

h_

The platform I/O handle owned by this object.

Non-Member Functions

Name

Description

connect_pair

Synchronously connect two AF_UNIX datagram sockets as a connected pair.

Template Parameters

Name

Description

Backend

A backend tag value (e.g., epoll) whose type provides the concrete implementation types.

See Also

local_datagram_socket, epoll_t, iocp_t

Created with MrDocs