Skip to main content

accept_bounded

Function accept_bounded 

Source
pub async fn accept_bounded(
    listener: &TcpListener,
    limiter: &ConnectionLimiter,
    refusal: &[u8],
    protocol: &str,
    status_tx: Option<&UnboundedSender<String>>,
) -> Result<(TcpStream, SocketAddr, ConnectionPermit)>
Expand description

Accept the next connection the server has room for, refusing the ones it does not.

Returns only admitted peers. A peer over the cap is answered with refusal (skipped when empty), logged at WARN with decision=fail_closed_connection_cap, closed, and never seen by the caller.

Err means the listener failed, which is the caller’s signal to break its accept loop — exactly the errors TcpListener::accept already returns.