boost::corosio::tcp_server::stop

Stop accepting connections.

Synopsis

void
stop();

Description

Signals all listening ports to stop accepting new connections and requests cancellation of active workers via their stop tokens.

This function returns immediately; it does not wait for workers to finish. Pending I/O operations complete asynchronously.

Calling stop() on a non‐running server has no effect.

Effects

‐ Closes all acceptors (pending accepts complete with error). ‐ Requests stop on each active worker's stop token. ‐ Workers observing their stop token should exit promptly.

Postconditions

No new connections will be accepted. Active workers continue until they observe their stop token or complete naturally.

What Happens Next

After calling stop(): 1. Let ioc.run() return (drains pending completions). 2. Call join to wait for accept loops to finish. 3. Only then is it safe to restart or destroy the server.

Thread Safety

Not thread safe.

See Also

join, start

Created with MrDocs