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

Wait for readiness for input (recv) or output (send)&period;

== Synopsis

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

[source,cpp,subs="verbatim,replacements,macros,-callouts"]
----
&lsqb;&lsqb;nodiscard&rsqb;&rsqb;
virtual
bool
Wait(
    std::chrono::milliseconds timeout,
    xref:Sock/Event.adoc[Event] requested,
    xref:Sock/Event.adoc[Event]* occurred = nullptr) const;
----

== Return Value

true on success (or timeout, if `occurred` of 0 is returned), false otherwise

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

[cols="1,4"]
|===
| Name| Description
| *timeout* [in]
| Wait this much for at least one of the requested events to occur&period;
| *requested* [in]
| Wait for those events, bitwise&hyphen;or of `RecvEvent` and `SendEvent`&period;
| *occurred* [out]
| If not nullptr and the function returns `true`, then this indicates which of the requested events occurred (`ErrorEvent` will be added, even if not requested, if an exceptional event occurs on the socket)&period; A timeout is indicated by return value of `true` and `occurred` being set to 0&period;
|===


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