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

recv(2) wrapper&period; Equivalent to `recv(m&lowbar;socket, buf, len, flags)&semi;`&period; Code that uses this wrapper can be unit tested if this method is overridden by a mock Sock implementation&period;

== Synopsis

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

[source,cpp,subs="verbatim,replacements,macros,-callouts"]
----
&lsqb;&lsqb;nodiscard&rsqb;&rsqb;
virtual
ssize&lowbar;t
Recv(
    void* buf,
    size&lowbar;t len,
    int flags) const;
----

== Return Value

Number of bytes received, 0 on orderly shutdown, or &hyphen;1 on error (with errno set)&period;

[NOTE]
====
The return value https://en.cppreference.com/cpp/language/attributes/nodiscard[should not be discarded^].
====
== Parameters

[cols="1,4"]
|===
| Name| Description
| *buf*
| Destination buffer for the received bytes&period;
| *len*
| Maximum number of bytes to receive&period;
| *flags*
| Flags passed through to `recv(2)`&period;
|===


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