boost::corosio::native_tcp_socket
An asynchronous TCP socket with devirtualized I/O operations.
Synopsis
template<auto Backend>
class native_tcp_socket
: public tcp_socket
Description
This class template inherits from tcp_socket and shadows the async operations (read_some, write_some, connect) with versions that call the backend implementation directly, allowing the compiler to inline through the entire call chain.
Non‐async operations (open, close, cancel, socket options) remain unchanged and dispatch through the compiled library.
A native_tcp_socket IS‐A tcp_socket and can be passed to any function expecting tcp_socket& or io_stream&, in which case virtual dispatch is used transparently.
Thread Safety
Same as tcp_socket.
Example
#include <boost/corosio/native/native_tcp_socket.hpp>
native_io_context<epoll> ctx;
native_tcp_socket<epoll> s(ctx);
s.open();
auto [ec] = co_await s.connect(ep);
auto [ec2, n] = co_await s.read_some(buf);
Types
Name |
Description |
RAII wrapper for I/O object implementation lifetime. |
|
Service interface for I/O object lifecycle management. |
|
Options for SO_LINGER socket option. |
Member Functions
Name |
Description |
|
Constructors |
|
Assignment operators |
Cancel any pending asynchronous operations. |
|
Close the socket. |
|
Asynchronously connect to a remote endpoint. |
|
Return the execution context. |
|
Check if the socket is open. |
|
Get the current SO_KEEPALIVE setting. |
|
Get the current SO_LINGER setting. |
|
Get the local endpoint of the socket. |
|
Get the native socket handle. |
|
Get the current TCP_NODELAY setting. |
|
Open the socket. |
|
Asynchronously read data from the socket. |
|
Get the receive buffer size (SO_RCVBUF). |
|
Get the remote endpoint of the socket. |
|
Get the send buffer size (SO_SNDBUF). |
|
Enable or disable SO_KEEPALIVE. |
|
Set the SO_LINGER option. |
|
Enable or disable TCP_NODELAY (disable Nagle's algorithm). |
|
Set the receive buffer size (SO_RCVBUF). |
|
Set the send buffer size (SO_SNDBUF). |
|
Disable sends or receives on the socket. |
|
Asynchronously write data to the socket. |
Protected Types
Name |
Description |
Awaitable for async read operations. |
|
Awaitable for async write operations. |
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
tcp_socket, epoll_t, iocp_t
Created with MrDocs