[#Sock-Accept]
= xref:Sock.adoc[Sock]::Accept
:relfileprefix: ../
:mrdocs:

accept(2) wrapper&period; Equivalent to `std&colon;&colon;make&lowbar;unique&lt;Sock&gt;(accept(m&lowbar;socket, addr, addr&lowbar;len))`&period; Code that uses this wrapper can be unit tested if this method is overridden by a mock Sock implementation&period; The returned unique&lowbar;ptr is empty if `accept()` failed in which case errno will be set&period;

== Synopsis

Declared in `&lt;util&sol;sock&period;h&gt;`

[source,cpp,subs="verbatim,replacements,macros,-callouts"]
----
&lsqb;&lsqb;nodiscard&rsqb;&rsqb;
virtual
std::unique&lowbar;ptr&lt;Sock&gt;
Accept(
    sockaddr* addr,
    socklen&lowbar;t* addr&lowbar;len) const;
----

== Return Value

A `Sock` wrapping the accepted connection, or an empty unique&lowbar;ptr on error&period;

[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&period;
| *addr&lowbar;len*
| On input the size of `addr`, on output the actual address size, or nullptr&period;
|===


[.small]#Created with https://www.mrdocs.com[MrDocs]#
