boost::corosio::local_stream_acceptor
An asynchronous Unix stream acceptor for coroutine I/O.
Synopsis
class local_stream_acceptor
: public io_object
Description
This class provides asynchronous Unix domain stream accept operations that return awaitable types. The acceptor binds to a local endpoint (filesystem path) and listens for incoming connections.
The library does NOT automatically unlink the socket path on close. Callers are responsible for removing the socket file before bind or after close, or pass bind_option::unlink_existing to bind.
Thread Safety
Distinct objects: Safe. Shared objects: Unsafe. An acceptor must not have concurrent accept operations.
Semantics
Wraps the platform Unix domain socket listener. Operations dispatch to OS accept APIs via the io_context reactor. Cancellation propagates through the IoAwaitable stop_token or via cancel; cancelled operations resume with errc::operation_canceled.
Example
io_context ioc;
local_stream_acceptor acc(ioc);
acc.open();
if (auto ec = acc.bind(
local_endpoint("/tmp/my.sock"),
bind_option::unlink_existing))
return ec;
if (auto ec = acc.listen())
return ec;
local_stream_socket peer(ioc);
auto [ec] = co_await acc.accept(peer);
if (!ec) {
// peer is now connected
}
Types
Name |
Description |
RAII wrapper for I/O object implementation lifetime. |
|
Define backend hooks for local stream acceptor operations. |
|
Service interface for I/O object lifecycle management. |
Member Functions
Name |
Description |
|
Constructors |
|
Destructor |
|
Assignment operators |
|
|
Bind to a local endpoint. |
|
Close the acceptor. |
|
Return the execution context. |
|
Check if the acceptor has a native handle. |
|
Start listening for incoming connections. |
|
Create the acceptor socket. |
|
Release ownership of the native socket handle. |
|
Protected Member Functions
Name |
Description |
|
Constructors |
|
Move assign from another I/O object. |
Protected Static Member Functions
Name |
Description |
Create a handle bound to a service found in the context. |
|
See Also
local_stream_socket, local_endpoint, local_stream
Created with MrDocs