---
name: "zmq_ctx_get"
section: "3"
platform: "linux"
package: "zeromq"
version: "4.3.5-3"
release: "Arch Linux 2026-11-01"
platforms: ["linux"]
url: "https://new.carta.tech/zmq_ctx_get"
---

# zmq\_ctx\_get(3)

get context options

## NAME

zmq\_ctx\_get - get context options

## SYNOPSIS

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

## 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

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

### 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

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

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

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

### ZMQ\_IPV6: Set IPv6 option

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

### 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

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

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

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

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

**EINVAL**

The requested option *option\_name* is unknown.

**EFAULT**

The provided *context* is invalid.

## 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

[**zmq\_ctx\_set**(3)](/zmq_ctx_set/3.md) [**zmq**(7)](/zmq/7.md)

## 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**.
