boost::corosio::tcp_acceptor
An asynchronous TCP acceptor for coroutine I/O.
Synopsis
Declared in <boost/corosio/tcp_acceptor.hpp>
class tcp_acceptor
: public io_object
Description
This class provides asynchronous TCP accept operations that return awaitable types. The acceptor binds to a local endpoint and listens for incoming connections.
Each accept operation participates in the affine awaitable protocol, ensuring coroutines resume on the correct executor.
Thread Safety
Distinct objects: Safe. Shared objects: Unsafe. An acceptor must not have concurrent accept operations.
Semantics
Wraps the platform TCP listener. Operations dispatch to OS accept APIs via the io_context reactor.
Example
io_context ioc;
tcp_acceptor acc(ioc);
acc.listen(endpoint(8080)); // Bind to port 8080
tcp_socket peer(ioc);
auto [ec] = co_await acc.accept(peer);
if (!ec) {
// peer is now a connected socket
auto [ec2, n] = co_await peer.read_some(buf);
}
Types
Name |
Description |
RAII wrapper for I/O object implementation lifetime. |
|
Forward declaration for platform‐specific implementation. |
|
Base interface for platform I/O implementations. |
|
Service interface for I/O object lifecycle management. |
Member Functions
Name |
Description |
|
Constructors |
|
Destructor. |
|
Move assignment operator. |
Initiate an asynchronous accept operation. |
|
Cancel any pending asynchronous operations. |
|
Close the acceptor. |
|
Return the execution context. |
|
Check if the acceptor is listening. |
|
Open, bind, and listen on an endpoint. |
|
Get the local endpoint of the acceptor. |
Protected Data Members
Name |
Created with MrDocs