[#Sock-GetSockOpt] = xref:Sock.adoc[Sock]::GetSockOpt :relfileprefix: ../ :mrdocs: getsockopt(2) wrapper. Equivalent to `getsockopt(m_socket, level, opt_name, opt_val, opt_len)`. Code that uses this wrapper can be unit tested if this method is overridden by a mock Sock implementation. == Synopsis Declared in `<util/sock.h>` [source,cpp,subs="verbatim,replacements,macros,-callouts"] ---- [[nodiscard]] virtual int GetSockOpt( int level, int opt_name, void* opt_val, socklen_t* opt_len) const; ---- == Return Value 0 on success, or ‐1 on error (with errno set). [NOTE] ==== The return value https://en.cppreference.com/cpp/language/attributes/nodiscard[should not be discarded^]. ==== == Parameters [cols="1,4"] |=== | Name| Description | *level* | Protocol level at which the option resides. | *opt_name* | Name of the option to query. | *opt_val* | Buffer that receives the option value. | *opt_len* | On input the size of `opt_val`, on output the actual option size. |=== [.small]#Created with https://www.mrdocs.com[MrDocs]#