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

NAME

6       zmq_ctx_set - set context options
7

SYNOPSIS

9       int zmq_ctx_set (void *context, int option_name, int option_value);
10

DESCRIPTION

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

RETURN VALUE

154       The zmq_ctx_set() function returns zero if successful. Otherwise it
155       returns -1 and sets errno to one of the values defined below.
156

ERRORS

158       EINVAL
159           The requested option option_name is unknown.
160

EXAMPLE

162       Setting a limit on the number of sockets.
163
164           void *context = zmq_ctx_new ();
165           zmq_ctx_set (context, ZMQ_MAX_SOCKETS, 256);
166           int max_sockets = zmq_ctx_get (context, ZMQ_MAX_SOCKETS);
167           assert (max_sockets == 256);
168
169

SEE ALSO

171       zmq_ctx_get(3) zmq(7)
172

AUTHORS

174       This page was written by the 0MQ community. To make a change please
175       read the 0MQ Contribution Policy at
176       http://www.zeromq.org/docs:contributing.
177
178
179
1800MQ 4.3.4                         07/23/2022                    ZMQ_CTX_SET(3)
Impressum