2023-10-21 01:50:38 +02:00
|
|
|
= zmq_ctx_set(3)
|
2012-03-20 01:41:20 +01:00
|
|
|
|
|
|
|
|
2023-10-21 01:50:38 +02:00
|
|
|
== NAME
|
2012-03-20 01:41:20 +01:00
|
|
|
|
|
|
|
zmq_ctx_set - set context options
|
|
|
|
|
|
|
|
|
2023-10-21 01:50:38 +02:00
|
|
|
== SYNOPSIS
|
2012-03-20 01:41:20 +01:00
|
|
|
*int zmq_ctx_set (void '*context', int 'option_name', int 'option_value');*
|
|
|
|
|
|
|
|
|
2023-10-21 01:50:38 +02:00
|
|
|
== DESCRIPTION
|
2012-03-20 01:41:20 +01:00
|
|
|
The _zmq_ctx_set()_ function shall set the option specified by the
|
|
|
|
'option_name' argument to the value of the 'option_value' argument.
|
|
|
|
|
|
|
|
The _zmq_ctx_set()_ function accepts the following options:
|
|
|
|
|
|
|
|
|
2014-11-17 11:56:59 +01:00
|
|
|
ZMQ_BLOCKY: Fix blocky behavior
|
|
|
|
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
|
|
|
By default the context will block, forever, on a zmq_ctx_term call. The
|
|
|
|
assumption behind this behavior is that abrupt termination will cause
|
|
|
|
message loss. Most real applications use some form of handshaking to ensure
|
|
|
|
applications receive termination messages, and then terminate the context
|
|
|
|
with 'ZMQ_LINGER' set to zero on all sockets. This setting is an easier way
|
|
|
|
to get the same result. When 'ZMQ_BLOCKY' is set to false, all new sockets
|
|
|
|
are given a linger timeout of zero. You must still close all sockets before
|
2016-02-01 23:00:06 +01:00
|
|
|
calling zmq_ctx_term.
|
2014-11-17 11:56:59 +01:00
|
|
|
|
|
|
|
[horizontal]
|
2015-07-20 23:05:48 +02:00
|
|
|
Default value:: true (old behavior)
|
2014-11-17 11:56:59 +01:00
|
|
|
|
|
|
|
|
2012-03-20 01:41:20 +01:00
|
|
|
ZMQ_IO_THREADS: Set number of I/O threads
|
|
|
|
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
|
|
|
The 'ZMQ_IO_THREADS' argument specifies the size of the 0MQ thread pool to
|
|
|
|
handle I/O operations. If your application is using only the 'inproc'
|
|
|
|
transport for messaging you may set this to zero, otherwise set it to at
|
|
|
|
least one. This option only applies before creating any sockets on the
|
|
|
|
context.
|
|
|
|
|
|
|
|
[horizontal]
|
|
|
|
Default value:: 1
|
|
|
|
|
2016-02-09 10:51:51 +01:00
|
|
|
|
2015-07-16 08:59:19 +02:00
|
|
|
ZMQ_THREAD_SCHED_POLICY: Set scheduling policy for I/O threads
|
|
|
|
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
|
|
|
The 'ZMQ_THREAD_SCHED_POLICY' argument sets the scheduling policy for
|
|
|
|
internal context's thread pool. This option is not available on windows.
|
|
|
|
Supported values for this option can be found in sched.h file,
|
|
|
|
or at http://man7.org/linux/man-pages/man2/sched_setscheduler.2.html.
|
|
|
|
This option only applies before creating any sockets on the context.
|
|
|
|
|
|
|
|
[horizontal]
|
|
|
|
Default value:: -1
|
|
|
|
|
2016-02-09 10:51:51 +01:00
|
|
|
|
2015-07-16 08:59:19 +02:00
|
|
|
ZMQ_THREAD_PRIORITY: Set scheduling priority for I/O threads
|
|
|
|
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
|
|
|
The 'ZMQ_THREAD_PRIORITY' argument sets scheduling priority for
|
|
|
|
internal context's thread pool. This option is not available on windows.
|
|
|
|
Supported values for this option depend on chosen scheduling policy.
|
2017-10-17 14:03:53 +02:00
|
|
|
On Linux, when the scheduler policy is SCHED_OTHER, SCHED_IDLE or SCHED_BATCH, the OS scheduler
|
2023-05-23 16:40:46 +02:00
|
|
|
will not use the thread priority but rather the thread "nice value"; in such cases,
|
|
|
|
if 'ZMQ_THREAD_PRIORITY' is set to a strictly positive value,
|
2017-10-17 14:03:53 +02:00
|
|
|
the system call "nice" will be used to set the nice value to -20 (max priority) instead of
|
|
|
|
adjusting the thread priority (which must be zero for those scheduling policies).
|
2015-07-16 08:59:19 +02:00
|
|
|
Details can be found in sched.h file, or at http://man7.org/linux/man-pages/man2/sched_setscheduler.2.html.
|
|
|
|
This option only applies before creating any sockets on the context.
|
|
|
|
|
|
|
|
[horizontal]
|
|
|
|
Default value:: -1
|
|
|
|
|
2016-02-09 10:51:51 +01:00
|
|
|
|
2017-10-25 09:55:47 +02:00
|
|
|
ZMQ_THREAD_AFFINITY_CPU_ADD: Add a CPU to list of affinity for I/O threads
|
|
|
|
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
|
|
|
The 'ZMQ_THREAD_AFFINITY_CPU_ADD' argument adds a specific CPU to the affinity list for the internal
|
2017-10-16 13:43:34 +02:00
|
|
|
context's thread pool. This option is only supported on Linux.
|
|
|
|
This option only applies before creating any sockets on the context.
|
2017-10-25 09:55:47 +02:00
|
|
|
The default affinity list is empty and means that no explicit CPU-affinity will be set on
|
|
|
|
internal context's threads.
|
|
|
|
|
|
|
|
[horizontal]
|
|
|
|
Default value:: -1
|
|
|
|
|
|
|
|
|
|
|
|
ZMQ_THREAD_AFFINITY_CPU_REMOVE: Remove a CPU to list of affinity for I/O threads
|
|
|
|
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
|
|
|
The 'ZMQ_THREAD_AFFINITY_CPU_REMOVE' argument removes a specific CPU to the affinity list for the internal
|
|
|
|
context's thread pool. This option is only supported on Linux.
|
|
|
|
This option only applies before creating any sockets on the context.
|
|
|
|
The default affinity list is empty and means that no explicit CPU-affinity will be set on
|
|
|
|
internal context's threads.
|
2017-10-16 13:43:34 +02:00
|
|
|
|
|
|
|
[horizontal]
|
|
|
|
Default value:: -1
|
|
|
|
|
|
|
|
|
2017-10-17 14:11:42 +02:00
|
|
|
ZMQ_THREAD_NAME_PREFIX: Set name prefix for I/O threads
|
2017-10-17 14:18:46 +02:00
|
|
|
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
2017-10-17 14:11:42 +02:00
|
|
|
The 'ZMQ_THREAD_NAME_PREFIX' argument sets a numeric prefix to each thread
|
|
|
|
created for the internal context's thread pool. This option is only supported on Linux.
|
|
|
|
This option is useful to help debugging done via "top -H" or "gdb"; in case
|
|
|
|
multiple processes on the system are using ZeroMQ it is useful to provide through
|
|
|
|
this context option an application-specific prefix to distinguish ZeroMQ background
|
|
|
|
threads that belong to different processes.
|
|
|
|
This option only applies before creating any sockets on the context.
|
|
|
|
|
|
|
|
[horizontal]
|
|
|
|
Default value:: -1
|
|
|
|
|
|
|
|
|
|
|
|
|
2016-02-09 10:51:51 +01:00
|
|
|
ZMQ_MAX_MSGSZ: Set maximum message size
|
|
|
|
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
|
|
|
The 'ZMQ_MAX_MSGSZ' argument sets the maximum allowed size
|
|
|
|
of a message sent in the context. You can query the maximal
|
2023-10-21 01:50:38 +02:00
|
|
|
allowed value with xref:zmq_ctx_get.adoc[zmq_ctx_get] using the
|
2016-02-09 10:51:51 +01:00
|
|
|
'ZMQ_MAX_MSGSZ' option.
|
|
|
|
|
|
|
|
[horizontal]
|
|
|
|
Default value:: INT_MAX
|
|
|
|
Maximum value:: INT_MAX
|
|
|
|
|
|
|
|
|
2020-02-04 21:00:07 +01:00
|
|
|
ZMQ_ZERO_COPY_RECV: Specify message decoding strategy
|
2018-03-05 13:19:20 +01:00
|
|
|
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
2020-02-04 21:00:07 +01:00
|
|
|
The 'ZMQ_ZERO_COPY_RECV' argument specifies whether the message decoder should
|
2018-03-05 13:19:20 +01:00
|
|
|
use a zero copy strategy when receiving messages. The zero copy strategy can
|
|
|
|
lead to increased memory usage in some cases. This option allows you to use the
|
|
|
|
older copying strategy. You can query the value of this option with
|
2023-10-21 01:50:38 +02:00
|
|
|
xref:zmq_ctx_get.adoc[zmq_ctx_get] using the 'ZMQ_ZERO_COPY_RECV' option.
|
2018-03-19 21:15:24 +01:00
|
|
|
NOTE: in DRAFT state, not yet available in stable releases.
|
2018-03-05 13:19:20 +01:00
|
|
|
|
|
|
|
[horizontal]
|
|
|
|
Default value:: 1
|
|
|
|
|
|
|
|
|
2012-03-20 01:41:20 +01:00
|
|
|
ZMQ_MAX_SOCKETS: Set maximum number of sockets
|
|
|
|
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
|
|
|
The 'ZMQ_MAX_SOCKETS' argument sets the maximum number of sockets allowed
|
2014-02-13 15:54:06 +01:00
|
|
|
on the context. You can query the maximal allowed value with
|
2023-10-21 01:50:38 +02:00
|
|
|
xref:zmq_ctx_get.adoc[zmq_ctx_get] using the 'ZMQ_SOCKET_LIMIT' option.
|
2012-03-20 01:41:20 +01:00
|
|
|
|
|
|
|
[horizontal]
|
2019-07-23 02:37:00 +02:00
|
|
|
Default value:: 1023
|
2012-03-20 01:41:20 +01:00
|
|
|
|
2016-02-09 10:51:51 +01:00
|
|
|
|
2013-01-31 21:52:30 +01:00
|
|
|
ZMQ_IPV6: Set IPv6 option
|
|
|
|
~~~~~~~~~~~~~~~~~~~~~~~~~
|
|
|
|
The 'ZMQ_IPV6' argument sets the IPv6 value for all sockets created in
|
|
|
|
the context from this point onwards. A value of `1` means IPv6 is
|
|
|
|
enabled, while `0` means the socket will use only IPv4. When IPv6 is
|
|
|
|
enabled, a socket will connect to, or accept connections from, both
|
|
|
|
IPv4 and IPv6 hosts.
|
|
|
|
|
|
|
|
[horizontal]
|
|
|
|
Default value:: 0
|
|
|
|
|
2012-03-20 01:41:20 +01:00
|
|
|
|
2023-10-21 01:50:38 +02:00
|
|
|
== RETURN VALUE
|
2012-03-20 01:41:20 +01:00
|
|
|
The _zmq_ctx_set()_ function returns zero if successful. Otherwise it
|
|
|
|
returns `-1` and sets 'errno' to one of the values defined below.
|
|
|
|
|
|
|
|
|
2023-10-21 01:50:38 +02:00
|
|
|
== ERRORS
|
2012-03-20 01:41:20 +01:00
|
|
|
*EINVAL*::
|
|
|
|
The requested option _option_name_ is unknown.
|
|
|
|
|
|
|
|
|
2023-10-21 01:50:38 +02:00
|
|
|
== EXAMPLE
|
2012-03-20 01:41:20 +01:00
|
|
|
.Setting a limit on the number of sockets
|
|
|
|
----
|
|
|
|
void *context = zmq_ctx_new ();
|
|
|
|
zmq_ctx_set (context, ZMQ_MAX_SOCKETS, 256);
|
|
|
|
int max_sockets = zmq_ctx_get (context, ZMQ_MAX_SOCKETS);
|
|
|
|
assert (max_sockets == 256);
|
|
|
|
----
|
|
|
|
|
|
|
|
|
2023-10-21 01:50:38 +02:00
|
|
|
== SEE ALSO
|
2023-11-03 11:36:47 +01:00
|
|
|
* xref:zmq_ctx_get.adoc[zmq_ctx_get]
|
|
|
|
* xref:zmq.adoc[zmq]
|
2012-03-20 01:41:20 +01:00
|
|
|
|
|
|
|
|
2023-10-21 01:50:38 +02:00
|
|
|
== AUTHORS
|
2013-04-11 18:53:02 +02:00
|
|
|
This page was written by the 0MQ community. To make a change please
|
2023-11-22 23:18:23 +01:00
|
|
|
read the 0MQ Contribution Policy at <https://zeromq.org/how-to-contribute/>.
|