Sock::GetSockOpt

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>

[[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 should not be discarded.

Parameters

NameDescription
levelProtocol level at which the option resides.
opt_nameName of the option to query.
opt_valBuffer that receives the option value.
opt_lenOn input the size of opt_val, on output the actual option size.