---
name: "zmq_ctx_set_ext"
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_set_ext"
---

# zmq\_ctx\_set\_ext(3)

set extended context options

## NAME

zmq\_ctx\_set\_ext - set extended context options

## SYNOPSIS

**int zmq\_ctx\_set\_ext (void** *\*context***, int** *option\_name***, const void** *\*option\_value***, size\_t** *option\_len***);**

## DESCRIPTION

The *zmq\_ctx\_set\_ext()* function shall set the option specified by the *option\_name* argument to the value pointed to by the *option\_value* argument for the 0MQ context pointed to by the *context* argument. The *option\_len* argument is the size of the option value in bytes. For options taking a value of type "character string", the provided byte data should either contain no zero bytes, or end in a single zero byte (terminating ASCII NUL character).

The *zmq\_ctx\_set\_ext()* function accepts all the option names accepted by *zmq\_ctx\_set()*. Options that make most sense to set using *zmq\_ctx\_set\_ext()* instead of *zmq\_ctx\_set()* are the following options:

### ZMQ\_THREAD\_NAME\_PREFIX: Set name prefix for I/O threads

The *ZMQ\_THREAD\_NAME\_PREFIX* argument sets a string 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.

| | |
| --- | --- |
| Option value type | character string |
| Option value unit | N/A |
| Default value | empty string |

## RETURN VALUE

The *zmq\_ctx\_set\_ext()* function returns zero 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 prefix on internal ZMQ thread names:**.

```
void *context = zmq_ctx_new ();
const char prefix[] = "MyApp";
size_t prefixLen = sizeof(prefix);
zmq_ctx_set (context, ZMQ_THREAD_NAME_PREFIX, &prefix, &prefixLen);
char buff[256];
size_t buffLen = sizeof(buff);
int rc = zmq_ctx_get (context, ZMQ_THREAD_NAME_PREFIX, &buff, &buffLen);
assert (rc == 0);
assert (buffLen == prefixLen);
```

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