blob: a8323d993bc087f20bbe81b90d5eaaa15e12f213 [file] [log] [blame]
sp_getsockopt(3)
================
NAME
----
sp_getsockopt - retreive a socket option
SYNOPSIS
--------
*#include <sp/sp.h>*
*int sp_getsockopt (int 's', int 'level', int 'option', void '*optval', size_t '*optvallen');*
DESCRIPTION
-----------
Retrieves the value for the 'option'. The 'level' argument specifies
the protocol level at which the option resides. For generic socket-level options
use _SP_SOL_SOCKET_ level. For socket-type-specific options use socket type
for 'level' argument (e.g. _SP_SUB_). For transport-specific options use ID of
the transport as the 'level' argument (e.g. _SP_TCP_).
The value is stored in the buffer pointed to by 'optval' argument. Size of the
buffer is specified by the 'optvallen' argument. If the size of the option is
greater than size of the buffer, the value will be silently truncated.
Otherwise, the 'optvallen' will be modified to indicate the actual length of
the option.
_<sp/sp.h>_ header defines generic socket-level options. The options are as
follows:
*SP_LINGER*::
Option type is int. Default is 1000.
*SP_SNDBUF*::
Option type is int. Default is 128kB.
*SP_RCVBUF*::
Option type is int. Default is 128kB.
*SP_SNDTIMEO*::
Option type is int. Default is 0 (no timeout).
*SP_RCVTIMEO*::
Option type is int. Default is 0 (no timeout).
*SP_RECONNECT_IVL*::
Option type is int. Default is 100.
*SP_RECONNECT_IVL_MAX*::
Option type is int. Default is 0.
RETURN VALUE
------------
If the function succeeds zero is returned. Otherwise, negative number is
returned and 'errno' is set to to one of the values defined below.
ERRORS
------
*EFAULT*::
The library is not initialised.
*EBADF*::
The provided socket is invalid.
*ENOPROTOOPT*::
The option is unknown at the level indicated.
*ETERM*::
The library is terminating.
EXAMPLE
-------
----
int linger;
size_t sz = sizeof (linger);
sp_getsockopt (s, SOL_SP, SP_LINGER, &linger, &sz);
----
SEE ALSO
--------
linknanomsg:sp_socket[3]
linknanomsg:sp_setsockopt[3]
linknanomsg:nanomsg[7]
AUTHORS
-------
Martin Sustrik <sustrik@250bpm.com>