nn_getsockopt(3compat)
| NN_GETSOCKOPT(3compat) | NNG Reference Manual | NN_GETSOCKOPT(3compat) |
NAME
nn_getsockopt - get socket option (compatible API)
SYNOPSIS
#include <nanomsg/nn.h> int nn_getsockopt(int sock, int level, int option, void *val, size_t *szp);
DESCRIPTION
The nn_getsockopt() function gets a socket option on socket sock. The option retrieved is determined by the level and option.
Note
This function is provided for API
compatibility with legacy libnanomsg. Consider using the relevant
modern API instead.
The value pointed to by szp must be initialized to the size of the buffer pointed to by val. No more than this many bytes of the option will be copied into the destination buffer on success. On success, the value pointed to by szp will be updated with the actual size of the option.
Tip
To determine the size to receive an option, first call this
function
with val set to NULL and the value addressed by
szp initialized to zero.
The level determines whether the option is a generic socket option, or is transport-specific. The values possible for level are as follows:
NN_SOL_SOCKET
NN_IPC
NN_TCP
NN_WS
The following generic socket options are possible (all are of type int and thus size 4, unless otherwise indicated.)
NN_SNDBUF
Note
In NNG buffers are sized as a count of messages rather than
bytes; accordingly this value is the queue depth multiplied by 1024
(representing an estimate that the average message size is 1kB).
Applications that have unusual message sizes may wish to adjust the value
used here accordingly.
NN_RCVBUF
Note
The same caveats for NN_SNDBUF apply here as well.
NN_SNDTIMEO
NN_RCVTIMEO
NN_RCVMAXSIZE
NN_RECONNECT_IVL
NN_RECONNECT_IVL_MAX
NN_LINGER
Note
This option was unreliable in early releases of libnanomsg,
and
is unsupported in NNG and recent libnanomsg releases.
Applications needing assurance of message delivery should either include an
explicit notification (automatic with the NN_REQ
protocol) or allow sufficient time for the socket to drain before closing
the socket or exiting.
NN_SNDPRIO
NN_RCVPRIO
NN_IPV4ONLY
NN_SOCKET_NAME
NN_MAXTTL
Note
Not all protocols offer this protection, so care should still be
used
in configuring device forwarding.
NN_DOMAIN
NN_PROTOCOL
NN_RCVFD
Note
The file descriptor should not be read or written by the
application,
and is not the same as any underlying descriptor used for network sockets.
NN_SNDFD
Note
The file descriptor should not be read or written by the
application,
and is not the same as any underlying descriptor used for network sockets.
Furthermore, the file descriptor should only be polled for
readability.
The following option is available for NN_REQ sockets using the NN_REQ level:
NN_REQ_RESEND_IVL
The following option is available for NN_SURVEYOR sockets using the NN_SURVEYOR level:
NN_SURVEYOR_DEADLINE
In addition, the following transport specific options are offered:
NN_IPC_SEC_ATTR
NN_IPC_OUTBUFSZ
NN_IPC_INBUFSZE
NN_TCP_NODELAY
NN_WS_MSG_TYPE
RETURN VALUES
This function returns zero on success, and -1 on failure.
ERRORS
EBADF
ENOMEM
ENOPROTOOPT
EINVAL
ETERM
EACCES
SEE ALSO
nng_socket(5), nn_close(3compat), nn_errno(3compat), nn_getsockopt(3compat), nng_compat(3compat), nng(7)
| 2026-06-29 |
