[#Sock-Accept] = xref:Sock.adoc[Sock]::Accept :relfileprefix: ../ :mrdocs: 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>` [source,cpp,subs="verbatim,replacements,macros,-callouts"] ---- [[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 https://en.cppreference.com/cpp/language/attributes/nodiscard[should not be discarded^]. ==== == Parameters [cols="1,4"] |=== | 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. |=== [.small]#Created with https://www.mrdocs.com[MrDocs]#