accept(2) wrapper. Equivalent to std::make_unique<Sock>(accept(m_socket, addr, addr_len)). Code that uses this wrapper can be unit tested if this method is overridden by a mock Sock implementation. The returned unique_ptr is empty if accept() failed in which case errno will be set.

Synopsis

Declared in <util/sock.h>

[[nodiscard]]
virtual
std::unique_ptr<Sock>
Accept(
    sockaddr* addr,
    socklen_t* addr_len) const;

Return Value

A Sock wrapping the accepted connection, or an empty unique_ptr on error.

Note

The return value should not be discarded.

Parameters

Name

Description

addr

Filled in with the address of the accepted peer, or nullptr.

addr_len

On input the size of addr, on output the actual address size, or nullptr.

Created with MrDocs