boost::corosio::local_stream_acceptor

Accepts inbound Unix domain stream connections, from a coroutine.

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 or abstract name) 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 (via bind_option::unlink_existing) or after close.

Thread Safety

Distinct objects: Safe. Shared objects: Unsafe. An acceptor must not have concurrent accept operations.

Example

capy::task<>
bind_listen_accept(corosio::io_context& ioc)
{
    corosio::local_stream_acceptor acc(ioc);
    if (auto ec = acc.open())
        co_return;
    if (auto ec = acc.bind(
            corosio::local_endpoint("/tmp/my_app.sock"),
            corosio::bind_option::unlink_existing))
        co_return;
    if (auto ec = acc.listen())
        co_return;

    auto [aec, peer] = co_await acc.accept();
    if (aec)
        co_return;
}

Base Classes

Name

Description

io_object

Owns the platform‐specific handle and execution context that a derived socket, timer, signal handler, or acceptor type uses to dispatch operations.

Types

Name

Description

handle

Owns a platform‐specific I/O implementation and destroys it when the handle goes out of scope.

implementation

Backends derive from this to implement accept, option, and lifecycle management.

io_service

Constructs, closes, and destroys platform implementations on behalf of an I/O object. Platform backends implement this interface.

Member Functions

Name

Description

local_stream_acceptor [constructor]

Constructors

~local_stream_acceptor [destructor] [virtual]

Closes the acceptor if open, cancelling any pending operations.

operator=

Assignment operators

accept

accept overloads

assign

Assign an existing native socket to this acceptor.

bind

Bind to a local endpoint.

cancel

Cancel pending asynchronous accept operations.

close

Close the acceptor.

context

Return the execution context.

get_option

Get a socket option from the acceptor.

is_open

Check if the acceptor has an open socket handle.

listen

Start listening for incoming connections.

local_endpoint

Return the local endpoint the acceptor is bound to.

native_handle

Get the native socket handle.

open

Create the acceptor socket.

release

Release ownership of the native socket handle.

set_option

Set a socket option on the acceptor.

wait

Wait for an incoming connection or readiness condition.

Protected Member Functions

Name

Description

local_stream_acceptor [constructor]

Constructors

operator=

Assignment operators

Protected Static Member Functions

Name

Description

create_handle

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

reset_peer_impl

Install an accepted implementation into the peer socket.

Protected Data Members

Name

Description

h_

The platform I/O handle owned by this object.

Derived Classes

Name

Description

native_local_stream_acceptor

Accepts Unix domain stream connections, calling the backend directly.

Created with MrDocs