1NN_GETSOCKOPT(3)                 nanomsg 1.1.5                NN_GETSOCKOPT(3)
2
3
4

NAME

6       nn_getsockopt - retrieve a socket option
7

SYNOPSIS

9       #include <nanomsg/nn.h>
10
11       int nn_getsockopt (int s, int level, int option, void *optval, size_t
12       *optvallen);
13

DESCRIPTION

15       Retrieves the value for the option. The level argument specifies the
16       protocol level at which the option resides. For generic socket-level
17       options use NN_SOL_SOCKET level. For socket-type-specific options use
18       socket type for level argument (e.g. NN_SUB). For transport-specific
19       options use ID of the transport as the level argument (e.g. NN_TCP).
20
21       The value is stored in the buffer pointed to by optval argument. Size
22       of the buffer is specified by the optvallen argument. If the size of
23       the option is greater than size of the buffer, the value will be
24       silently truncated. Otherwise, the optvallen will be modified to
25       indicate the actual length of the option.
26
27       <nanomsg/nn.h> header defines generic socket-level options
28       (NN_SOL_SOCKET level). The options are as follows:
29
30       NN_DOMAIN
31           Returns the domain constant as it was passed to nn_socket().
32
33       NN_PROTOCOL
34           Returns the protocol constant as it was passed to nn_socket().
35
36       NN_LINGER
37           Specifies how long the socket should try to send pending outbound
38           messages after nn_close() have been called, in milliseconds.
39           Negative value means infinite linger. The type of the option is
40           int. Default value is 1000 (1 second).
41
42       NN_SNDBUF
43           Size of the send buffer, in bytes. To prevent blocking for messages
44           larger than the buffer, exactly one message may be buffered in
45           addition to the data in the send buffer. The type of this option is
46           int. Default value is 128kB.
47
48       NN_RCVBUF
49           Size of the receive buffer, in bytes. To prevent blocking for
50           messages larger than the buffer, exactly one message may be
51           buffered in addition to the data in the receive buffer. The type of
52           this option is int. Default value is 128kB.
53
54       NN_RCVMAXSIZE
55           Maximum message size that can be received, in bytes. Negative value
56           means that the received size is limited only by available
57           addressable memory. The type of this option is int. Default is
58           1024kB.
59
60       NN_SNDTIMEO
61           The timeout for send operation on the socket, in milliseconds. If
62           message cannot be sent within the specified timeout, ETIMEDOUT
63           error is returned. Negative value means infinite timeout. The type
64           of the option is int. Default value is -1.
65
66       NN_RCVTIMEO
67           The timeout for recv operation on the socket, in milliseconds. If
68           message cannot be received within the specified timeout, ETIMEDOUT
69           error is returned. Negative value means infinite timeout. The type
70           of the option is int. Default value is -1.
71
72       NN_RECONNECT_IVL
73           For connection-based transports such as TCP, this option specifies
74           how long to wait, in milliseconds, when connection is broken before
75           trying to re-establish it. Note that actual reconnect interval may
76           be randomised to some extent to prevent severe reconnection storms.
77           The type of the option is int. Default value is 100 (0.1 second).
78
79       NN_RECONNECT_IVL_MAX
80           This option is to be used only in addition to NN_RECONNECT_IVL
81           option. It specifies maximum reconnection interval. On each
82           reconnect attempt, the previous interval is doubled until
83           NN_RECONNECT_IVL_MAX is reached. Value of zero means that no
84           exponential backoff is performed and reconnect interval is based
85           only on NN_RECONNECT_IVL. If NN_RECONNECT_IVL_MAX is less than
86           NN_RECONNECT_IVL, it is ignored. The type of the option is int.
87           Default value is 0.
88
89       NN_SNDPRIO
90           Retrieves outbound priority currently set on the socket. This
91           option has no effect on socket types that send messages to all the
92           peers. However, if the socket type sends each message to a single
93           peer (or a limited set of peers), peers with high priority take
94           precedence over peers with low priority. The type of the option is
95           int. Highest priority is 1, lowest priority is 16. Default value is
96           8.
97
98       NN_RCVPRIO
99           Sets inbound priority for endpoints subsequently added to the
100           socket. This option has no effect on socket types that are not able
101           to receive messages. When receiving a message, messages from peer
102           with higher priority are received before messages from peer with
103           lower priority. The type of the option is int. Highest priority is
104           1, lowest priority is 16. Default value is 8.
105
106       NN_IPV4ONLY
107           If set to 1, only IPv4 addresses are used. If set to 0, both IPv4
108           and IPv6 addresses are used. The type of the option is int. Default
109           value is 1.
110
111       NN_SNDFD
112           Retrieves a file descriptor that is readable when a message can be
113           sent to the socket. The descriptor should be used only for polling
114           and never read from or written to. The type of the option is same
115           as the type of file descriptor on the platform. That is, int on
116           POSIX-complaint platforms and SOCKET on Windows. The descriptor
117           becomes invalid and should not be used any more once the socket is
118           closed. This socket option is not available for unidirectional
119           recv-only socket types.
120
121       NN_RCVFD
122           Retrieves a file descriptor that is readable when a message can be
123           received from the socket. The descriptor should be used only for
124           polling and never read from or written to. The type of the option
125           is same as the type of file descriptor on the platform. That is,
126           int on POSIX-complaint platforms and SOCKET on Windows. The
127           descriptor becomes invalid and should not be used any more once the
128           socket is closed. This socket option is not available for
129           unidirectional send-only socket types.
130
131       NN_SOCKET_NAME
132           Socket name for error reporting and statistics. The type of the
133           option is string. Default value is "N" where N is socket integer.
134           This option is experimental, see nn_env(7) for details
135
136       NN_MAXTTL
137           Retrieves the maximum number of "hops" a message can go through
138           before it is dropped. Each time the message is received (for
139           example via the nn_device(3) function) counts as a single hop. This
140           provides a form of protection against inadvertent loops.
141

RETURN VALUE

143       If the function succeeds zero is returned. Otherwise, -1 is returned
144       and errno is set to to one of the values defined below.
145

ERRORS

147       EBADF
148           The provided socket is invalid.
149
150       ENOPROTOOPT
151           The option is unknown at the level indicated.
152
153       ETERM
154           The library is terminating.
155

EXAMPLE

157           int linger;
158           size_t sz = sizeof (linger);
159           nn_getsockopt (s, NN_SOL_SOCKET, NN_LINGER, &amp;linger, &amp;sz);
160

SEE ALSO

162       nn_socket(3) nn_setsockopt(3) nanomsg(7)
163

AUTHORS

165       Martin Sustrik <sustrik@250bpm.com> Garrett D’Amore
166       <garrett@damore.org>
167
168
169
170                                  2018-10-15                  NN_GETSOCKOPT(3)
Impressum