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
}

Base Classes

Name Description

io_object

Base class for platform I/O objects.

Types

Name

Description

handle

RAII wrapper for I/O object implementation lifetime.

implementation

Define backend hooks for local stream acceptor operations.

io_service

Service interface for I/O object lifecycle management.

Member Functions

Name

Description

local_stream_acceptor [constructor] [deleted]

Constructors

~local_stream_acceptor [destructor] [virtual]

Destructor

operator= [deleted]

Assignment operators

accept

accept overloads

bind

Bind to a local endpoint.

cancel

close

Close the acceptor.

context

Return the execution context.

get_option

is_open

Check if the acceptor has a native handle.

listen

Start listening for incoming connections.

local_endpoint

open

Create the acceptor socket.

release

Release ownership of the native socket handle.

set_option

Protected Member Functions

Name

Description

local_stream_acceptor [constructor]

Constructors

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.

reset_peer_impl

Protected Data Members

Name

Description

h_

The platform I/O handle owned by this object.

See Also

local_stream_socket, local_endpoint, local_stream

Created with MrDocs