PageRenderTime 51ms CodeModel.GetById 21ms RepoModel.GetById 1ms app.codeStats 0ms

/doc/zmq_getsockopt.txt

https://github.com/unixcrh/libzmq
Plain Text | 531 lines | 412 code | 119 blank | 0 comment | 0 complexity | 0edcc0def2fb34a2e915e6e0de2808a7 MD5 | raw file
Possible License(s): GPL-3.0, LGPL-3.0
  1. zmq_getsockopt(3)
  2. =================
  3. NAME
  4. ----
  5. zmq_getsockopt - get 0MQ socket options
  6. SYNOPSIS
  7. --------
  8. *int zmq_getsockopt (void '*socket', int 'option_name', void '*option_value', size_t '*option_len');*
  9. DESCRIPTION
  10. -----------
  11. The _zmq_getsockopt()_ function shall retrieve the value for the option
  12. specified by the 'option_name' argument for the 0MQ socket pointed to by the
  13. 'socket' argument, and store it in the buffer pointed to by the 'option_value'
  14. argument. The 'option_len' argument is the size in bytes of the buffer pointed
  15. to by 'option_value'; upon successful completion _zmq_getsockopt()_ shall
  16. modify the 'option_len' argument to indicate the actual size of the option
  17. value stored in the buffer.
  18. The following options can be retrieved with the _zmq_getsockopt()_ function:
  19. ZMQ_TYPE: Retrieve socket type
  20. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  21. The 'ZMQ_TYPE' option shall retrieve the socket type for the specified
  22. 'socket'. The socket type is specified at socket creation time and
  23. cannot be modified afterwards.
  24. [horizontal]
  25. Option value type:: int
  26. Option value unit:: N/A
  27. Default value:: N/A
  28. Applicable socket types:: all
  29. ZMQ_RCVMORE: More message data parts to follow
  30. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  31. The 'ZMQ_RCVMORE' option shall return True (1) if the message part last
  32. received from the 'socket' was a data part with more parts to follow. If there
  33. are no data parts to follow, this option shall return False (0).
  34. Refer to linkzmq:zmq_send[3] and linkzmq:zmq_recv[3] for a detailed description
  35. of multi-part messages.
  36. [horizontal]
  37. Option value type:: int
  38. Option value unit:: boolean
  39. Default value:: N/A
  40. Applicable socket types:: all
  41. ZMQ_SNDHWM: Retrieves high water mark for outbound messages
  42. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  43. The 'ZMQ_SNDHWM' option shall return the high water mark for outbound messages
  44. on the specified 'socket'. The high water mark is a hard limit on the maximum
  45. number of outstanding messages 0MQ shall queue in memory for any single peer
  46. that the specified 'socket' is communicating with. A value of zero means no
  47. limit.
  48. If this limit has been reached the socket shall enter an exceptional state and
  49. depending on the socket type, 0MQ shall take appropriate action such as
  50. blocking or dropping sent messages. Refer to the individual socket descriptions
  51. in linkzmq:zmq_socket[3] for details on the exact action taken for each socket
  52. type.
  53. [horizontal]
  54. Option value type:: int
  55. Option value unit:: messages
  56. Default value:: 1000
  57. Applicable socket types:: all
  58. ZMQ_RCVHWM: Retrieve high water mark for inbound messages
  59. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  60. The 'ZMQ_RCVHWM' option shall return the high water mark for inbound messages on
  61. the specified 'socket'. The high water mark is a hard limit on the maximum
  62. number of outstanding messages 0MQ shall queue in memory for any single peer
  63. that the specified 'socket' is communicating with. A value of zero means no
  64. limit.
  65. If this limit has been reached the socket shall enter an exceptional state and
  66. depending on the socket type, 0MQ shall take appropriate action such as
  67. blocking or dropping sent messages. Refer to the individual socket descriptions
  68. in linkzmq:zmq_socket[3] for details on the exact action taken for each socket
  69. type.
  70. [horizontal]
  71. Option value type:: int
  72. Option value unit:: messages
  73. Default value:: 1000
  74. Applicable socket types:: all
  75. ZMQ_AFFINITY: Retrieve I/O thread affinity
  76. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  77. The 'ZMQ_AFFINITY' option shall retrieve the I/O thread affinity for newly
  78. created connections on the specified 'socket'.
  79. Affinity determines which threads from the 0MQ I/O thread pool associated with
  80. the socket's _context_ shall handle newly created connections. A value of zero
  81. specifies no affinity, meaning that work shall be distributed fairly among all
  82. 0MQ I/O threads in the thread pool. For non-zero values, the lowest bit
  83. corresponds to thread 1, second lowest bit to thread 2 and so on. For example,
  84. a value of 3 specifies that subsequent connections on 'socket' shall be handled
  85. exclusively by I/O threads 1 and 2.
  86. See also linkzmq:zmq_init[3] for details on allocating the number of I/O
  87. threads for a specific _context_.
  88. [horizontal]
  89. Option value type:: uint64_t
  90. Option value unit:: N/A (bitmap)
  91. Default value:: 0
  92. Applicable socket types:: N/A
  93. ZMQ_IDENTITY: Set socket identity
  94. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  95. The 'ZMQ_IDENTITY' option shall retrieve the identity of the specified 'socket'.
  96. Socket identity is used only by request/reply pattern. Namely, it can be used
  97. in tandem with ROUTER socket to route messages to the peer with specific
  98. identity.
  99. Identity should be at least one byte and at most 255 bytes long. Identities
  100. starting with binary zero are reserved for use by 0MQ infrastructure.
  101. [horizontal]
  102. Option value type:: binary data
  103. Option value unit:: N/A
  104. Default value:: NULL
  105. Applicable socket types:: all
  106. ZMQ_RATE: Retrieve multicast data rate
  107. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  108. The 'ZMQ_RATE' option shall retrieve the maximum send or receive data rate for
  109. multicast transports using the specified 'socket'.
  110. [horizontal]
  111. Option value type:: int
  112. Option value unit:: kilobits per second
  113. Default value:: 100
  114. Applicable socket types:: all, when using multicast transports
  115. ZMQ_RECOVERY_IVL: Get multicast recovery interval
  116. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  117. The 'ZMQ_RECOVERY_IVL' option shall retrieve the recovery interval for
  118. multicast transports using the specified 'socket'. The recovery interval
  119. determines the maximum time in milliseconds that a receiver can be absent from a
  120. multicast group before unrecoverable data loss will occur.
  121. [horizontal]
  122. Option value type:: int
  123. Option value unit:: milliseconds
  124. Default value:: 10000
  125. Applicable socket types:: all, when using multicast transports
  126. ZMQ_SNDBUF: Retrieve kernel transmit buffer size
  127. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  128. The 'ZMQ_SNDBUF' option shall retrieve the underlying kernel transmit buffer
  129. size for the specified 'socket'. A value of zero means that the OS default is
  130. in effect. For details refer to your operating system documentation for the
  131. 'SO_SNDBUF' socket option.
  132. [horizontal]
  133. Option value type:: int
  134. Option value unit:: bytes
  135. Default value:: 0
  136. Applicable socket types:: all
  137. ZMQ_RCVBUF: Retrieve kernel receive buffer size
  138. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  139. The 'ZMQ_RCVBUF' option shall retrieve the underlying kernel receive buffer
  140. size for the specified 'socket'. A value of zero means that the OS default is
  141. in effect. For details refer to your operating system documentation for the
  142. 'SO_RCVBUF' socket option.
  143. [horizontal]
  144. Option value type:: int
  145. Option value unit:: bytes
  146. Default value:: 0
  147. Applicable socket types:: all
  148. ZMQ_LINGER: Retrieve linger period for socket shutdown
  149. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  150. The 'ZMQ_LINGER' option shall retrieve the linger period for the specified
  151. 'socket'. The linger period determines how long pending messages which have
  152. yet to be sent to a peer shall linger in memory after a socket is closed with
  153. linkzmq:zmq_close[3], and further affects the termination of the socket's
  154. context with linkzmq:zmq_term[3]. The following outlines the different
  155. behaviours:
  156. * The default value of '-1' specifies an infinite linger period. Pending
  157. messages shall not be discarded after a call to _zmq_close()_; attempting to
  158. terminate the socket's context with _zmq_term()_ shall block until all
  159. pending messages have been sent to a peer.
  160. * The value of '0' specifies no linger period. Pending messages shall be
  161. discarded immediately when the socket is closed with _zmq_close()_.
  162. * Positive values specify an upper bound for the linger period in milliseconds.
  163. Pending messages shall not be discarded after a call to _zmq_close()_;
  164. attempting to terminate the socket's context with _zmq_term()_ shall block
  165. until either all pending messages have been sent to a peer, or the linger
  166. period expires, after which any pending messages shall be discarded.
  167. [horizontal]
  168. Option value type:: int
  169. Option value unit:: milliseconds
  170. Default value:: -1 (infinite)
  171. Applicable socket types:: all
  172. ZMQ_RECONNECT_IVL: Retrieve reconnection interval
  173. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  174. The 'ZMQ_RECONNECT_IVL' option shall retrieve the initial reconnection interval
  175. for the specified 'socket'. The reconnection interval is the period 0MQ shall
  176. wait between attempts to reconnect disconnected peers when using
  177. connection-oriented transports. The value -1 means no reconnection.
  178. NOTE: The reconnection interval may be randomized by 0MQ to prevent
  179. reconnection storms in topologies with a large number of peers per socket.
  180. [horizontal]
  181. Option value type:: int
  182. Option value unit:: milliseconds
  183. Default value:: 100
  184. Applicable socket types:: all, only for connection-oriented transports
  185. ZMQ_RECONNECT_IVL_MAX: Retrieve maximum reconnection interval
  186. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  187. The 'ZMQ_RECONNECT_IVL_MAX' option shall retrieve the maximum reconnection
  188. interval for the specified 'socket'. This is the maximum period 0MQ shall wait
  189. between attempts to reconnect. On each reconnect attempt, the previous interval
  190. shall be doubled untill ZMQ_RECONNECT_IVL_MAX is reached. This allows for
  191. exponential backoff strategy. Default value means no exponential backoff is
  192. performed and reconnect interval calculations are only based on
  193. ZMQ_RECONNECT_IVL.
  194. NOTE: Values less than ZMQ_RECONNECT_IVL will be ignored.
  195. [horizontal]
  196. Option value type:: int
  197. Option value unit:: milliseconds
  198. Default value:: 0 (only use ZMQ_RECONNECT_IVL)
  199. Applicable socket types:: all, only for connection-oriented transport
  200. ZMQ_BACKLOG: Retrieve maximum length of the queue of outstanding connections
  201. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  202. The 'ZMQ_BACKLOG' option shall retrieve the maximum length of the queue of
  203. outstanding peer connections for the specified 'socket'; this only applies to
  204. connection-oriented transports. For details refer to your operating system
  205. documentation for the 'listen' function.
  206. [horizontal]
  207. Option value type:: int
  208. Option value unit:: connections
  209. Default value:: 100
  210. Applicable socket types:: all, only for connection-oriented transports
  211. ZMQ_MAXMSGSIZE: Maximum acceptable inbound message size
  212. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  213. The option shall retrieve limit for the inbound messages. If a peer sends
  214. a message larger than ZMQ_MAXMSGSIZE it is disconnected. Value of -1 means
  215. 'no limit'.
  216. [horizontal]
  217. Option value type:: int64_t
  218. Option value unit:: bytes
  219. Default value:: -1
  220. Applicable socket types:: all
  221. ZMQ_MULTICAST_HOPS: Maximum network hops for multicast packets
  222. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  223. The option shall retrieve time-to-live used for outbound multicast packets.
  224. The default of 1 means that the multicast packets don't leave the local network.
  225. [horizontal]
  226. Option value type:: int
  227. Option value unit:: network hops
  228. Default value:: 1
  229. Applicable socket types:: all, when using multicast transports
  230. ZMQ_RCVTIMEO: Maximum time before a socket operation returns with EAGAIN
  231. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  232. Retrieve the timeout for recv operation on the socket. If the value is `0`,
  233. _zmq_recv(3)_ will return immediately, with a EAGAIN error if there is no
  234. message to receive. If the value is `-1`, it will block until a message is
  235. available. For all other values, it will wait for a message for that amount
  236. of time before returning with an EAGAIN error.
  237. [horizontal]
  238. Option value type:: int
  239. Option value unit:: milliseconds
  240. Default value:: -1 (infinite)
  241. Applicable socket types:: all
  242. ZMQ_SNDTIMEO: Maximum time before a socket operation returns with EAGAIN
  243. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  244. Retrieve the timeout for send operation on the socket. If the value is `0`,
  245. _zmq_send(3)_ will return immediately, with a EAGAIN error if the message
  246. cannot be sent. If the value is `-1`, it will block until the message is sent.
  247. For all other values, it will try to send the message for that amount of time
  248. before returning with an EAGAIN error.
  249. [horizontal]
  250. Option value type:: int
  251. Option value unit:: milliseconds
  252. Default value:: -1 (infinite)
  253. Applicable socket types:: all
  254. ZMQ_IPV6: Retrieve IPv6 socket status
  255. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  256. Retrieve the IPv6 option for the socket. A value of `1` means IPv6 is
  257. enabled on the socket, while `0` means the socket will use only IPv4.
  258. When IPv6 is enabled the socket will connect to, or accept connections
  259. from, both IPv4 and IPv6 hosts.
  260. [horizontal]
  261. Option value type:: int
  262. Option value unit:: boolean
  263. Default value:: 0 (false)
  264. Applicable socket types:: all, when using TCP transports.
  265. ZMQ_IPV4ONLY: Retrieve IPv4-only socket override status
  266. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  267. Retrieve the IPv4-only option for the socket. This option is deprecated.
  268. Please use the ZMQ_IPV6 option.
  269. [horizontal]
  270. Option value type:: int
  271. Option value unit:: boolean
  272. Default value:: 1 (true)
  273. Applicable socket types:: all, when using TCP transports.
  274. ZMQ_DELAY_ATTACH_ON_CONNECT: Retrieve attach-on-connect value
  275. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  276. Retrieve the state of the attach on connect value. If set to `1`, will delay the
  277. attachment of a pipe on connect until the underlying connection has completed.
  278. This will cause the socket to block if there are no other connections, but will
  279. prevent queues from filling on pipes awaiting connection.
  280. [horizontal]
  281. Option value type:: int
  282. Option value unit:: boolean
  283. Default value:: 0 (false)
  284. Applicable socket types:: all, primarily when using TCP/IPC transports.
  285. ZMQ_FD: Retrieve file descriptor associated with the socket
  286. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  287. The 'ZMQ_FD' option shall retrieve the file descriptor associated with the
  288. specified 'socket'. The returned file descriptor can be used to integrate the
  289. socket into an existing event loop; the 0MQ library shall signal any pending
  290. events on the socket in an _edge-triggered_ fashion by making the file
  291. descriptor become ready for reading.
  292. NOTE: The ability to read from the returned file descriptor does not
  293. necessarily indicate that messages are available to be read from, or can be
  294. written to, the underlying socket; applications must retrieve the actual event
  295. state with a subsequent retrieval of the 'ZMQ_EVENTS' option.
  296. NOTE: The returned file descriptor is also used internally by the 'zmq_send'
  297. and 'zmq_recv' functions. As the descriptor is edge triggered, applications
  298. must update the state of 'ZMQ_EVENTS' after each invocation of 'zmq_send'
  299. or 'zmq_recv'.To be more explicit: after calling 'zmq_send' the socket may
  300. become readable (and vice versa) without triggering a read event on the
  301. file descriptor.
  302. CAUTION: The returned file descriptor is intended for use with a 'poll' or
  303. similar system call only. Applications must never attempt to read or write data
  304. to it directly, neither should they try to close it.
  305. [horizontal]
  306. Option value type:: int on POSIX systems, SOCKET on Windows
  307. Option value unit:: N/A
  308. Default value:: N/A
  309. Applicable socket types:: all
  310. ZMQ_EVENTS: Retrieve socket event state
  311. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  312. The 'ZMQ_EVENTS' option shall retrieve the event state for the specified
  313. 'socket'. The returned value is a bit mask constructed by OR'ing a combination
  314. of the following event flags:
  315. *ZMQ_POLLIN*::
  316. Indicates that at least one message may be received from the specified socket
  317. without blocking.
  318. *ZMQ_POLLOUT*::
  319. Indicates that at least one message may be sent to the specified socket without
  320. blocking.
  321. The combination of a file descriptor returned by the 'ZMQ_FD' option being
  322. ready for reading but no actual events returned by a subsequent retrieval of
  323. the 'ZMQ_EVENTS' option is valid; applications should simply ignore this case
  324. and restart their polling operation/event loop.
  325. [horizontal]
  326. Option value type:: int
  327. Option value unit:: N/A (flags)
  328. Default value:: N/A
  329. Applicable socket types:: all
  330. ZMQ_LAST_ENDPOINT: Retrieve the last endpoint set
  331. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  332. The 'ZMQ_LAST_ENDPOINT' option shall retrieve the last endpoint bound for
  333. TCP and IPC transports. The returned value will be a string in the form of
  334. a ZMQ DSN. Note that if the TCP host is INADDR_ANY, indicated by a *, then
  335. the returned address will be 0.0.0.0 (for IPv4).
  336. [horizontal]
  337. Option value type:: character string
  338. Option value unit:: N/A
  339. Default value:: NULL
  340. Applicable socket types:: all, when binding TCP or IPC transports
  341. ZMQ_TCP_KEEPALIVE: Override SO_KEEPALIVE socket option
  342. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  343. Override 'SO_KEEPALIVE' socket option(where supported by OS).
  344. The default value of `-1` means to skip any overrides and leave it to OS default.
  345. [horizontal]
  346. Option value type:: int
  347. Option value unit:: -1,0,1
  348. Default value:: -1 (leave to OS default)
  349. Applicable socket types:: all, when using TCP transports.
  350. ZMQ_TCP_KEEPALIVE_IDLE: Override TCP_KEEPCNT(or TCP_KEEPALIVE on some OS)
  351. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  352. Override 'TCP_KEEPCNT'(or 'TCP_KEEPALIVE' on some OS) socket option(where supported by OS).
  353. The default value of `-1` means to skip any overrides and leave it to OS default.
  354. [horizontal]
  355. Option value type:: int
  356. Option value unit:: -1,>0
  357. Default value:: -1 (leave to OS default)
  358. Applicable socket types:: all, when using TCP transports.
  359. ZMQ_TCP_KEEPALIVE_CNT: Override TCP_KEEPCNT socket option
  360. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  361. Override 'TCP_KEEPCNT' socket option(where supported by OS).
  362. The default value of `-1` means to skip any overrides and leave it to OS default.
  363. [horizontal]
  364. Option value type:: int
  365. Option value unit:: -1,>0
  366. Default value:: -1 (leave to OS default)
  367. Applicable socket types:: all, when using TCP transports.
  368. ZMQ_TCP_KEEPALIVE_INTVL: Override TCP_KEEPINTVL socket option
  369. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  370. Override 'TCP_KEEPINTVL' socket option(where supported by OS).
  371. The default value of `-1` means to skip any overrides and leave it to OS default.
  372. [horizontal]
  373. Option value type:: int
  374. Option value unit:: -1,>0
  375. Default value:: -1 (leave to OS default)
  376. Applicable socket types:: all, when using TCP transports.
  377. RETURN VALUE
  378. ------------
  379. The _zmq_getsockopt()_ function shall return zero if successful. Otherwise it
  380. shall return `-1` and set 'errno' to one of the values defined below.
  381. ERRORS
  382. ------
  383. *EINVAL*::
  384. The requested option _option_name_ is unknown, or the requested _option_len_ or
  385. _option_value_ is invalid, or the size of the buffer pointed to by
  386. _option_value_, as specified by _option_len_, is insufficient for storing the
  387. option value.
  388. *ETERM*::
  389. The 0MQ 'context' associated with the specified 'socket' was terminated.
  390. *ENOTSOCK*::
  391. The provided 'socket' was invalid.
  392. *EINTR*::
  393. The operation was interrupted by delivery of a signal.
  394. EXAMPLE
  395. -------
  396. .Retrieving the high water mark for outgoing messages
  397. ----
  398. /* Retrieve high water mark into sndhwm */
  399. int sndhwm;
  400. size_t sndhwm_size = sizeof (sndhwm);
  401. rc = zmq_getsockopt (socket, ZMQ_SNDHWM, &sndhwm, &sndhwm_size);
  402. assert (rc == 0);
  403. ----
  404. SEE ALSO
  405. --------
  406. linkzmq:zmq_setsockopt[3]
  407. linkzmq:zmq_socket[3]
  408. linkzmq:zmq[7]
  409. AUTHORS
  410. -------
  411. This 0MQ manual page was written by Martin Sustrik <sustrik@250bpm.com> and
  412. Martin Lucina <mato@kotelna.sk>.