Creates a new ØMQ context and sets any provided context options. Sockets need to be explicitly associated with a new context during construction.
Optional
options: {An optional object with options that will be set on the context during creation.
Optional
blocky?: booleanZMQ_BLOCKY
By default the context will block forever when closed at process exit. 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 Socket.linger set to zero on all sockets. This setting is an easier way to get the same result. When blocky is set to false
, all new sockets are given a linger timeout of zero. You must still close all sockets before exiting.
Optional
ioZMQ_IO_THREADS
Size of the ØMQ 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 (default).
Optional
ipv6?: booleanZMQ_IPV6
Enable or disable IPv6. When IPv6 is enabled, a socket will connect to, or accept connections from, both IPv4 and IPv6 hosts.
Optional
maxZMQ_MAX_MSGSZ
Maximum allowed size of a message sent in the context.
Optional
maxZMQ_MAX_SOCKETS
Maximum number of sockets allowed on the context.
Optional
threadZMQ_THREAD_PRIORITY
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. Details can be found at http://man7.org/linux/man-pages/man2/sched_setscheduler.2.html. This option only applies before creating any sockets on the context.
Optional
threadZMQ_THREAD_SCHED_POLICY
Scheduling policy for internal context's thread pool. This option is not available on Windows. Supported values for this option can be found at http://man7.org/linux/man-pages/man2/sched_setscheduler.2.html. This option only applies before creating any sockets on the context.
ZMQ_BLOCKY
By default the context will block forever when closed at process exit. 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 Socket.linger set to zero on all sockets. This setting is an easier way to get the same result. When blocky is set to false
, all new sockets are given a linger timeout of zero. You must still close all sockets before exiting.
ZMQ_IO_THREADS
Size of the ØMQ 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 (default).
ZMQ_IPV6
Enable or disable IPv6. When IPv6 is enabled, a socket will connect to, or accept connections from, both IPv4 and IPv6 hosts.
ZMQ_MAX_MSGSZ
Maximum allowed size of a message sent in the context.
ZMQ_MAX_SOCKETS
Maximum number of sockets allowed on the context.
Readonly
maxZMQ_SOCKET_LIMIT
Largest number of sockets that can be set with maxSockets.
ZMQ_THREAD_PRIORITY
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. Details can be found at http://man7.org/linux/man-pages/man2/sched_setscheduler.2.html. This option only applies before creating any sockets on the context.
ZMQ_THREAD_SCHED_POLICY
Scheduling policy for internal context's thread pool. This option is not available on Windows. Supported values for this option can be found at http://man7.org/linux/man-pages/man2/sched_setscheduler.2.html. This option only applies before creating any sockets on the context.
A ØMQ context. Contexts manage the background I/O to send and receive messages of their associated sockets.
It is usually not necessary to instantiate a new context - the global context is used for new sockets by default. The global context is the only context that is shared between threads (when using worker_threads). Custom contexts can only be used in the same thread.
Note: By default all contexts (including the global context) will prevent the process from terminating if there are any messages in an outgoing queue, even if the associated socket was closed. For some applications this is unnecessary or unwanted. Consider setting Context.blocky to
false
or setting Socket.linger for each new socket.