Sock::SetSockOpt

setsockopt(2) wrapper. Equivalent to setsockopt(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
SetSockOpt(
    int level,
    int opt_name,
    void const* 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 set.
opt_valBuffer holding the option value to set.
opt_lenSize in bytes of opt_val.