zmq_ctx_set.txt 6.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197
  1. zmq_ctx_set(3)
  2. ==============
  3. NAME
  4. ----
  5. zmq_ctx_set - set context options
  6. SYNOPSIS
  7. --------
  8. *int zmq_ctx_set (void '*context', int 'option_name', int 'option_value');*
  9. DESCRIPTION
  10. -----------
  11. The _zmq_ctx_set()_ function shall set the option specified by the
  12. 'option_name' argument to the value of the 'option_value' argument.
  13. The _zmq_ctx_set()_ function accepts the following options:
  14. ZMQ_BLOCKY: Fix blocky behavior
  15. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  16. By default the context will block, forever, on a zmq_ctx_term call. The
  17. assumption behind this behavior is that abrupt termination will cause
  18. message loss. Most real applications use some form of handshaking to ensure
  19. applications receive termination messages, and then terminate the context
  20. with 'ZMQ_LINGER' set to zero on all sockets. This setting is an easier way
  21. to get the same result. When 'ZMQ_BLOCKY' is set to false, all new sockets
  22. are given a linger timeout of zero. You must still close all sockets before
  23. calling zmq_ctx_term.
  24. [horizontal]
  25. Default value:: true (old behavior)
  26. ZMQ_IO_THREADS: Set number of I/O threads
  27. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  28. The 'ZMQ_IO_THREADS' argument specifies the size of the 0MQ thread pool to
  29. handle I/O operations. If your application is using only the 'inproc'
  30. transport for messaging you may set this to zero, otherwise set it to at
  31. least one. This option only applies before creating any sockets on the
  32. context.
  33. [horizontal]
  34. Default value:: 1
  35. ZMQ_THREAD_SCHED_POLICY: Set scheduling policy for I/O threads
  36. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  37. The 'ZMQ_THREAD_SCHED_POLICY' argument sets the scheduling policy for
  38. internal context's thread pool. This option is not available on windows.
  39. Supported values for this option can be found in sched.h file,
  40. or at http://man7.org/linux/man-pages/man2/sched_setscheduler.2.html.
  41. This option only applies before creating any sockets on the context.
  42. [horizontal]
  43. Default value:: -1
  44. ZMQ_THREAD_PRIORITY: Set scheduling priority for I/O threads
  45. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  46. The 'ZMQ_THREAD_PRIORITY' argument sets scheduling priority for
  47. internal context's thread pool. This option is not available on windows.
  48. Supported values for this option depend on chosen scheduling policy.
  49. On Linux, when the scheduler policy is SCHED_OTHER, SCHED_IDLE or SCHED_BATCH, the OS scheduler
  50. will not use the thread priority but rather the thread "nice value"; in such cases
  51. the system call "nice" will be used to set the nice value to -20 (max priority) instead of
  52. adjusting the thread priority (which must be zero for those scheduling policies).
  53. Details can be found in sched.h file, or at http://man7.org/linux/man-pages/man2/sched_setscheduler.2.html.
  54. This option only applies before creating any sockets on the context.
  55. [horizontal]
  56. Default value:: -1
  57. ZMQ_THREAD_AFFINITY_CPU_ADD: Add a CPU to list of affinity for I/O threads
  58. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  59. The 'ZMQ_THREAD_AFFINITY_CPU_ADD' argument adds a specific CPU to the affinity list for the internal
  60. context's thread pool. This option is only supported on Linux.
  61. This option only applies before creating any sockets on the context.
  62. The default affinity list is empty and means that no explicit CPU-affinity will be set on
  63. internal context's threads.
  64. [horizontal]
  65. Default value:: -1
  66. ZMQ_THREAD_AFFINITY_CPU_REMOVE: Remove a CPU to list of affinity for I/O threads
  67. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  68. The 'ZMQ_THREAD_AFFINITY_CPU_REMOVE' argument removes a specific CPU to the affinity list for the internal
  69. context's thread pool. This option is only supported on Linux.
  70. This option only applies before creating any sockets on the context.
  71. The default affinity list is empty and means that no explicit CPU-affinity will be set on
  72. internal context's threads.
  73. [horizontal]
  74. Default value:: -1
  75. ZMQ_THREAD_NAME_PREFIX: Set name prefix for I/O threads
  76. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  77. The 'ZMQ_THREAD_NAME_PREFIX' argument sets a numeric prefix to each thread
  78. created for the internal context's thread pool. This option is only supported on Linux.
  79. This option is useful to help debugging done via "top -H" or "gdb"; in case
  80. multiple processes on the system are using ZeroMQ it is useful to provide through
  81. this context option an application-specific prefix to distinguish ZeroMQ background
  82. threads that belong to different processes.
  83. This option only applies before creating any sockets on the context.
  84. [horizontal]
  85. Default value:: -1
  86. ZMQ_MAX_MSGSZ: Set maximum message size
  87. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  88. The 'ZMQ_MAX_MSGSZ' argument sets the maximum allowed size
  89. of a message sent in the context. You can query the maximal
  90. allowed value with linkzmq:zmq_ctx_get[3] using the
  91. 'ZMQ_MAX_MSGSZ' option.
  92. [horizontal]
  93. Default value:: INT_MAX
  94. Maximum value:: INT_MAX
  95. ZMQ_ZERO_COPY_RECV: Specify message decoding strategy
  96. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  97. The 'ZMQ_ZERO_COPY_RECV' argument specifies whether the message decoder should
  98. use a zero copy strategy when receiving messages. The zero copy strategy can
  99. lead to increased memory usage in some cases. This option allows you to use the
  100. older copying strategy. You can query the value of this option with
  101. linkzmq:zmq_ctx_get[3] using the 'ZMQ_ZERO_COPY_RECV' option.
  102. NOTE: in DRAFT state, not yet available in stable releases.
  103. [horizontal]
  104. Default value:: 1
  105. ZMQ_MAX_SOCKETS: Set maximum number of sockets
  106. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  107. The 'ZMQ_MAX_SOCKETS' argument sets the maximum number of sockets allowed
  108. on the context. You can query the maximal allowed value with
  109. linkzmq:zmq_ctx_get[3] using the 'ZMQ_SOCKET_LIMIT' option.
  110. [horizontal]
  111. Default value:: 1023
  112. ZMQ_IPV6: Set IPv6 option
  113. ~~~~~~~~~~~~~~~~~~~~~~~~~
  114. The 'ZMQ_IPV6' argument sets the IPv6 value for all sockets created in
  115. the context from this point onwards. A value of `1` means IPv6 is
  116. enabled, while `0` means the socket will use only IPv4. When IPv6 is
  117. enabled, a socket will connect to, or accept connections from, both
  118. IPv4 and IPv6 hosts.
  119. [horizontal]
  120. Default value:: 0
  121. RETURN VALUE
  122. ------------
  123. The _zmq_ctx_set()_ function returns zero if successful. Otherwise it
  124. returns `-1` and sets 'errno' to one of the values defined below.
  125. ERRORS
  126. ------
  127. *EINVAL*::
  128. The requested option _option_name_ is unknown.
  129. EXAMPLE
  130. -------
  131. .Setting a limit on the number of sockets
  132. ----
  133. void *context = zmq_ctx_new ();
  134. zmq_ctx_set (context, ZMQ_MAX_SOCKETS, 256);
  135. int max_sockets = zmq_ctx_get (context, ZMQ_MAX_SOCKETS);
  136. assert (max_sockets == 256);
  137. ----
  138. SEE ALSO
  139. --------
  140. linkzmq:zmq_ctx_get[3]
  141. linkzmq:zmq[7]
  142. AUTHORS
  143. -------
  144. This page was written by the 0MQ community. To make a change please
  145. read the 0MQ Contribution Policy at <http://www.zeromq.org/docs:contributing>.