ZMQ\_CTX\_GET(3) 0MQ Manual ZMQ\_CTX\_GET(3)

# [NAME](#NAME)

zmq\_ctx\_get - get context options

# [SYNOPSIS](#SYNOPSIS)

**int zmq\_ctx\_get (void \*context, int option\_name);**

# [DESCRIPTION](#DESCRIPTION)

The *zmq\_ctx\_get()* function shall return the option specified by the *option\_name* argument.

The *zmq\_ctx\_get()* function accepts the following option names:

## [ZMQ\_IO\_THREADS: Get number of I/O threads](#ZMQ_IO_THREADS:_Get_number_of_I/O_threads)

The *ZMQ\_IO\_THREADS* argument returns the size of the 0MQ thread pool for this context.

## [ZMQ\_MAX\_SOCKETS: Get maximum number of sockets](#ZMQ_MAX_SOCKETS:_Get_maximum_number_of_sockets)

The *ZMQ\_MAX\_SOCKETS* argument returns the maximum number of sockets allowed for this context.

## [ZMQ\_MAX\_MSGSZ: Get maximum message size](#ZMQ_MAX_MSGSZ:_Get_maximum_message_size)

The *ZMQ\_MAX\_MSGSZ* argument returns the maximum size of a message allowed for this context. Default value is INT\_MAX.

## [ZMQ\_ZERO\_COPY\_RECV: Get message decoding strategy](#ZMQ_ZERO_COPY_RECV:_Get_message_decoding_strategy)

The *ZMQ\_ZERO\_COPY\_RECV* argument return whether message decoder uses a zero copy strategy when receiving messages. Default value is 1. NOTE: in DRAFT state, not yet available in stable releases.

## [ZMQ\_SOCKET\_LIMIT: Get largest configurable number of sockets](#ZMQ_SOCKET_LIMIT:_Get_largest_configurable_number_of_sockets)

The *ZMQ\_SOCKET\_LIMIT* argument returns the largest number of sockets that [**zmq\_ctx\_set**(3)](/man/os/zeromq/zmq_ctx_set.3) will accept.

## [ZMQ\_IPV6: Set IPv6 option](#ZMQ_IPV6:_Set_IPv6_option)

The *ZMQ\_IPV6* argument returns the IPv6 option for the context.

## [ZMQ\_BLOCKY: Get blocky setting](#ZMQ_BLOCKY:_Get_blocky_setting)

The *ZMQ\_BLOCKY* argument returns 1 if the context will block on terminate, zero if the "block forever on context termination" gambit was disabled by setting ZMQ\_BLOCKY to false on all new contexts.

## [ZMQ\_THREAD\_SCHED\_POLICY: Get scheduling policy for I/O threads](#ZMQ_THREAD_SCHED_POLICY:_Get_scheduling_policy_for_I/O_threads)

The *ZMQ\_THREAD\_SCHED\_POLICY* argument returns the scheduling policy for internal context’s thread pool.

## [ZMQ\_THREAD\_NAME\_PREFIX: Get name prefix for I/O threads](#ZMQ_THREAD_NAME_PREFIX:_Get_name_prefix_for_I/O_threads)

The *ZMQ\_THREAD\_NAME\_PREFIX* argument gets the numeric prefix of each thread created for the internal context’s thread pool.

## [ZMQ\_MSG\_T\_SIZE: Get the zmq\_msg\_t size at runtime](#ZMQ_MSG_T_SIZE:_Get_the_zmq_msg_t_size_at_runtime)

The *ZMQ\_MSG\_T\_SIZE* argument returns the size of the zmq\_msg\_t structure at runtime, as defined in the include/zmq.h public header. This is useful for example for FFI bindings that can’t simply do a sizeof().

# [RETURN VALUE](#RETURN_VALUE)

The *zmq\_ctx\_get()* function returns a value of 0 or greater if successful. Otherwise it returns -1 and sets *errno* to one of the values defined below.

# [ERRORS](#ERRORS)

**EINVAL**

The requested option *option\_name* is unknown.

**EFAULT**

The provided *context* is invalid.

# [EXAMPLE](#EXAMPLE)

**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);
```

**Switching off the context deadlock gambit**.

```
zmq_ctx_set (ctx, ZMQ_BLOCKY, false);
```

# [SEE ALSO](#SEE_ALSO)

[**zmq\_ctx\_set**(3)](/man/os/zeromq/zmq_ctx_set.3) [**zmq**(7)](/man/os/zeromq/zmq.7)

# [AUTHORS](#AUTHORS)

This page was written by the 0MQ community. To make a change please read the 0MQ Contribution Policy at **http://www.zeromq.org/docs:contributing**.

10/26/2026 0MQ 4.3.5

---

Document: zmq_ctx_get(3) from zeromq 4.3.5-r15 (Chainguard OS)
Source: https://github.com/zeromq/libzmq
