1ZMQ_GETSOCKOPT(3)                 0MQ Manual                 ZMQ_GETSOCKOPT(3)
2
3
4

NAME

6       zmq_getsockopt - get 0MQ socket options
7

SYNOPSIS

9       int zmq_getsockopt (void *socket, int option_name, void *option_value,
10       size_t *option_len);
11

DESCRIPTION

13       The zmq_getsockopt() function shall retrieve the value for the option
14       specified by the option_name argument for the 0MQ socket pointed to by
15       the socket argument, and store it in the buffer pointed to by the
16       option_value argument. The option_len argument is the size in bytes of
17       the buffer pointed to by option_value; upon successful completion
18       zmq_getsockopt() shall modify the option_len argument to indicate the
19       actual size of the option value stored in the buffer.
20
21       The following options can be retrieved with the zmq_getsockopt()
22       function:
23
24   ZMQ_TYPE: Retrieve socket type
25       The ZMQ_TYPE option shall retrieve the socket type for the specified
26       socket. The socket type is specified at socket creation time and cannot
27       be modified afterwards.
28
29
30       Option value type         int
31
32       Option value unit         N/A
33
34       Default value             N/A
35
36       Applicable socket types   all
37
38
39   ZMQ_RCVMORE: More message parts to follow
40       The ZMQ_RCVMORE option shall return a boolean value indicating if the
41       multi-part message currently being read from the specified socket has
42       more message parts to follow. If there are no message parts to follow
43       or if the message currently being read is not a multi-part message a
44       value of zero shall be returned. Otherwise, a value of 1 shall be
45       returned.
46
47       Refer to zmq_send(3) and zmq_recv(3) for a detailed description of
48       sending/receiving multi-part messages.
49
50
51       Option value type         int64_t
52
53       Option value unit         boolean
54
55       Default value             N/A
56
57       Applicable socket types   all
58
59
60   ZMQ_HWM: Retrieve high water mark
61       The ZMQ_HWM option shall retrieve the high water mark for the specified
62       socket. The high water mark is a hard limit on the maximum number of
63       outstanding messages 0MQ shall queue in memory for any single peer that
64       the specified socket is communicating with.
65
66       If this limit has been reached the socket shall enter an exceptional
67       state and depending on the socket type, 0MQ shall take appropriate
68       action such as blocking or dropping sent messages. Refer to the
69       individual socket descriptions in zmq_socket(3) for details on the
70       exact action taken for each socket type.
71
72       The default ZMQ_HWM value of zero means "no limit".
73
74
75       Option value type         uint64_t
76
77       Option value unit         messages
78
79       Default value             0
80
81       Applicable socket types   all
82
83
84   ZMQ_SWAP: Retrieve disk offload size
85       The ZMQ_SWAP option shall retrieve the disk offload (swap) size for the
86       specified socket. A socket which has ZMQ_SWAP set to a non-zero value
87       may exceed it’s high water mark; in this case outstanding messages
88       shall be offloaded to storage on disk rather than held in memory.
89
90       The value of ZMQ_SWAP defines the maximum size of the swap space in
91       bytes.
92
93
94       Option value type         int64_t
95
96       Option value unit         bytes
97
98       Default value             0
99
100       Applicable socket types   all
101
102
103   ZMQ_AFFINITY: Retrieve I/O thread affinity
104       The ZMQ_AFFINITY option shall retrieve the I/O thread affinity for
105       newly created connections on the specified socket.
106
107       Affinity determines which threads from the 0MQ I/O thread pool
108       associated with the socket’s context shall handle newly created
109       connections. A value of zero specifies no affinity, meaning that work
110       shall be distributed fairly among all 0MQ I/O threads in the thread
111       pool. For non-zero values, the lowest bit corresponds to thread 1,
112       second lowest bit to thread 2 and so on. For example, a value of 3
113       specifies that subsequent connections on socket shall be handled
114       exclusively by I/O threads 1 and 2.
115
116       See also zmq_init(3) for details on allocating the number of I/O
117       threads for a specific context.
118
119
120       Option value type         uint64_t
121
122       Option value unit         N/A (bitmap)
123
124       Default value             0
125
126       Applicable socket types   N/A
127
128
129   ZMQ_IDENTITY: Retrieve socket identity
130       The ZMQ_IDENTITY option shall retrieve the identity of the specified
131       socket. Socket identity determines if existing 0MQ infrastructure
132       (message queues, forwarding devices) shall be identified with a
133       specific application and persist across multiple runs of the
134       application.
135
136       If the socket has no identity, each run of an application is completely
137       separate from other runs. However, with identity set the socket shall
138       re-use any existing 0MQ infrastructure configured by the previous
139       run(s). Thus the application may receive messages that were sent in the
140       meantime, message queue limits shall be shared with previous run(s) and
141       so on.
142
143       Identity can be at least one byte and at most 255 bytes long.
144       Identities starting with binary zero are reserved for use by 0MQ
145       infrastructure.
146
147
148       Option value type         binary data
149
150       Option value unit         N/A
151
152       Default value             NULL
153
154       Applicable socket types   all
155
156
157   ZMQ_RATE: Retrieve multicast data rate
158       The ZMQ_RATE option shall retrieve the maximum send or receive data
159       rate for multicast transports using the specified socket.
160
161
162       Option value type         int64_t
163
164       Option value unit         kilobits per second
165
166       Default value             100
167
168       Applicable socket types   all, when using multicast
169                                 transports
170
171
172   ZMQ_RECOVERY_IVL: Get multicast recovery interval
173       The ZMQ_RECOVERY_IVL option shall retrieve the recovery interval for
174       multicast transports using the specified socket. The recovery interval
175       determines the maximum time in seconds that a receiver can be absent
176       from a multicast group before unrecoverable data loss will occur.
177
178
179       Option value type         int64_t
180
181       Option value unit         seconds
182
183       Default value             10
184
185       Applicable socket types   all, when using multicast
186                                 transports
187
188
189   ZMQ_RECOVERY_IVL_MSEC: Get multicast recovery interval in milliseconds
190       The ZMQ_RECOVERY_IVL’_MSEC option shall retrieve the recovery interval,
191       in milliseconds, for multicast transports using the specified 'socket.
192       The recovery interval determines the maximum time in seconds that a
193       receiver can be absent from a multicast group before unrecoverable data
194       loss will occur.
195
196       For backward compatibility, the default value of ZMQ_RECOVERY_IVL_MSEC
197       is -1 indicating that the recovery interval should be obtained from the
198       ZMQ_RECOVERY_IVL option. However, if the ZMQ_RECOVERY_IVL_MSEC value is
199       not zero, then it will take precedence, and be used.
200
201
202       Option value type         int64_t
203
204       Option value unit         milliseconds
205
206       Default value             -1
207
208       Applicable socket types   all, when using multicast
209                                 transports
210
211
212   ZMQ_MCAST_LOOP: Control multicast loop-back
213       The ZMQ_MCAST_LOOP option controls whether data sent via multicast
214       transports can also be received by the sending host via loop-back. A
215       value of zero indicates that the loop-back functionality is disabled,
216       while the default value of 1 indicates that the loop-back functionality
217       is enabled. Leaving multicast loop-back enabled when it is not required
218       can have a negative impact on performance. Where possible, disable
219       ZMQ_MCAST_LOOP in production environments.
220
221
222       Option value type         int64_t
223
224       Option value unit         boolean
225
226       Default value             1
227
228       Applicable socket types   all, when using multicast
229                                 transports
230
231
232   ZMQ_SNDBUF: Retrieve kernel transmit buffer size
233       The ZMQ_SNDBUF option shall retrieve the underlying kernel transmit
234       buffer size for the specified socket. A value of zero means that the OS
235       default is in effect. For details refer to your operating system
236       documentation for the SO_SNDBUF socket option.
237
238
239       Option value type         uint64_t
240
241       Option value unit         bytes
242
243       Default value             0
244
245       Applicable socket types   all
246
247
248   ZMQ_RCVBUF: Retrieve kernel receive buffer size
249       The ZMQ_RCVBUF option shall retrieve the underlying kernel receive
250       buffer size for the specified socket. A value of zero means that the OS
251       default is in effect. For details refer to your operating system
252       documentation for the SO_RCVBUF socket option.
253
254
255       Option value type         uint64_t
256
257       Option value unit         bytes
258
259       Default value             0
260
261       Applicable socket types   all
262
263
264   ZMQ_LINGER: Retrieve linger period for socket shutdown
265       The ZMQ_LINGER option shall retrieve the linger period for the
266       specified socket. The linger period determines how long pending
267       messages which have yet to be sent to a peer shall linger in memory
268       after a socket is closed with zmq_close(3), and further affects the
269       termination of the socket’s context with zmq_term(3). The following
270       outlines the different behaviours:
271
272       ·   The default value of -1 specifies an infinite linger period.
273           Pending messages shall not be discarded after a call to
274           zmq_close(); attempting to terminate the socket’s context with
275           zmq_term() shall block until all pending messages have been sent to
276           a peer.
277
278       ·   The value of 0 specifies no linger period. Pending messages shall
279           be discarded immediately when the socket is closed with
280           zmq_close().
281
282       ·   Positive values specify an upper bound for the linger period in
283           milliseconds. Pending messages shall not be discarded after a call
284           to zmq_close(); attempting to terminate the socket’s context with
285           zmq_term() shall block until either all pending messages have been
286           sent to a peer, or the linger period expires, after which any
287           pending messages shall be discarded.
288
289           Option value type         int
290           Option value unit         milliseconds
291           Default value             -1 (infinite)
292           Applicable socket types   all
293
294
295   ZMQ_RECONNECT_IVL: Retrieve reconnection interval
296       The ZMQ_RECONNECT_IVL option shall retrieve the initial reconnection
297       interval for the specified socket. The reconnection interval is the
298       period 0MQ shall wait between attempts to reconnect disconnected peers
299       when using connection-oriented transports.
300
301           Note
302           The reconnection interval may be randomized by 0MQ to prevent
303           reconnection storms in topologies with a large number of peers per
304           socket.
305
306
307       Option value type         int
308
309       Option value unit         milliseconds
310
311       Default value             100
312
313       Applicable socket types   all, only for
314                                 connection-oriented
315                                 transports
316
317
318   ZMQ_RECONNECT_IVL_MAX: Retrieve maximum reconnection interval
319       The ZMQ_RECONNECT_IVL_MAX option shall retrieve the maximum
320       reconnection interval for the specified socket. This is the maximum
321       period 0MQ shall wait between attempts to reconnect. On each reconnect
322       attempt, the previous interval shall be doubled untill
323       ZMQ_RECONNECT_IVL_MAX is reached. This allows for exponential backoff
324       strategy. Default value means no exponential backoff is performed and
325       reconnect interval calculations are only based on ZMQ_RECONNECT_IVL.
326
327           Note
328           Values less than ZMQ_RECONNECT_IVL will be ignored.
329
330
331       Option value type         int
332
333       Option value unit         milliseconds
334
335
336       Default value             0 (only use
337                                 ZMQ_RECONNECT_IVL)
338
339       Applicable socket types   all, only for
340                                 connection-oriented
341                                 transport
342
343
344   ZMQ_BACKLOG: Retrieve maximum length of the queue of outstanding
345       connections
346       The ZMQ_BACKLOG option shall retrieve the maximum length of the queue
347       of outstanding peer connections for the specified socket; this only
348       applies to connection-oriented transports. For details refer to your
349       operating system documentation for the listen function.
350
351
352       Option value type         int
353
354       Option value unit         connections
355
356       Default value             100
357
358       Applicable socket types   all, only for
359                                 connection-oriented
360                                 transports
361
362
363   ZMQ_FD: Retrieve file descriptor associated with the socket
364       The ZMQ_FD option shall retrieve the file descriptor associated with
365       the specified socket. The returned file descriptor can be used to
366       integrate the socket into an existing event loop; the 0MQ library shall
367       signal any pending events on the socket in an edge-triggered fashion by
368       making the file descriptor become ready for reading.
369
370           Note
371           The ability to read from the returned file descriptor does not
372           necessarily indicate that messages are available to be read from,
373           or can be written to, the underlying socket; applications must
374           retrieve the actual event state with a subsequent retrieval of the
375           ZMQ_EVENTS option.
376
377           Caution
378           The returned file descriptor is intended for use with a poll or
379           similar system call only. Applications must never attempt to read
380           or write data to it directly, neither should they try to close it.
381
382
383       Option value type         int on POSIX systems,
384                                 SOCKET on Windows
385
386       Option value unit         N/A
387
388       Default value             N/A
389
390       Applicable socket types   all
391
392
393   ZMQ_EVENTS: Retrieve socket event state
394       The ZMQ_EVENTS option shall retrieve the event state for the specified
395       socket. The returned value is a bit mask constructed by OR’ing a
396       combination of the following event flags:
397
398       ZMQ_POLLIN
399           Indicates that at least one message may be received from the
400           specified socket without blocking.
401
402       ZMQ_POLLOUT
403           Indicates that at least one message may be sent to the specified
404           socket without blocking.
405
406       The combination of a file descriptor returned by the ZMQ_FD option
407       being ready for reading but no actual events returned by a subsequent
408       retrieval of the ZMQ_EVENTS option is valid; applications should simply
409       ignore this case and restart their polling operation/event loop.
410
411
412       Option value type         uint32_t
413
414       Option value unit         N/A (flags)
415
416       Default value             N/A
417
418       Applicable socket types   all
419
420

RETURN VALUE

422       The zmq_getsockopt() function shall return zero if successful.
423       Otherwise it shall return -1 and set errno to one of the values defined
424       below.
425

ERRORS

427       EINVAL
428           The requested option option_name is unknown, or the requested
429           option_len or option_value is invalid, or the size of the buffer
430           pointed to by option_value, as specified by option_len, is
431           insufficient for storing the option value.
432
433       ETERM
434           The 0MQ context associated with the specified socket was
435           terminated.
436
437       EFAULT
438           The provided socket was not valid (NULL).
439
440       EINTR
441           The operation was interrupted by delivery of a signal.
442

EXAMPLE

444       Retrieving the high water mark.
445
446           /* Retrieve high water mark into hwm */
447           int64_t hwm;
448           size_t hwm_size = sizeof (hwm);
449           rc = zmq_getsockopt (socket, ZMQ_HWM, &hwm, &hwm_size);
450           assert (rc == 0);
451
452

SEE ALSO

454       zmq_setsockopt(3) zmq_socket(3) zmq(7)
455

AUTHORS

457       This 0MQ manual page was written by Martin Sustrik
458       <sustrik@250bpm.com[1]> and Martin Lucina <mato@kotelna.sk[2]>.
459

NOTES

461        1. sustrik@250bpm.com
462           mailto:sustrik@250bpm.com
463
464        2. mato@kotelna.sk
465           mailto:mato@kotelna.sk
466
467
468
4690MQ 2.1.4                         03/30/2011                 ZMQ_GETSOCKOPT(3)
Impressum