ZMQ_CTX_SET_EXT(3)

πŸ“¦
version 4.3.5 Β· 2 versions
, in arch rolling

πŸ’… ZMQ_CTX_SET_EXT(3) β€” like, the extended context options glow-up ✨

okay bestie, so this one's from the 0MQ Manual (yes, that 0MQ) and it's about zmq_ctx_set_ext β€” the extra-strength version of setting context options. buckle up πŸŽ€


🌸 NAME 🌸

zmq_ctx_set_ext β€” set extended context options, periodt.

✨ SYNOPSIS ✨

int zmq_ctx_set_ext (void *context, int option_name, const void
*option_value, size_t option_len);

πŸ’– DESCRIPTION πŸ’–

so the zmq_ctx_set_ext() function shall (fancy word, love that for it) set the option picked by the option_name argument to the value that option_value points at β€” for the 0MQ context that context points to. and option_len? that's literally just the size of the option value in bytes, no cap.

quick vibe check for options that take a value of type "character string": the byte data you pass in should either contain no zero bytes or end in a single zero byte (that's your terminating ASCII NUL character 🫢). pick one, bestie, don't be weird about it.

zmq_ctx_set_ext() accepts all the option names that zmq_ctx_set() accepts, iconic behavior honestly. but the options that make the most sense to set with zmq_ctx_set_ext() instead of plain old zmq_ctx_set() are these ones right here:

πŸ‘‘ ZMQ_THREAD_NAME_PREFIX: set name prefix for I/O threads

the ZMQ_THREAD_NAME_PREFIX argument sets a string prefix on every thread created for the internal context's thread pool. main character energy for your threads fr.

it's only supported on Linux, just so you know. and it's genuinely useful for debugging via "top -H" or "gdb" β€” like, if multiple processes on the system are using ZeroMQ, it's lowkey great to hand this context option an application-specific prefix so you can tell apart the ZeroMQ background threads belonging to different processes. iykyk πŸ”₯

🚨 heads up: this option only applies before creating any sockets on the context. after that? too late, bestie.
  • Option value type β€” character string
  • Option value unit β€” N/A
  • Default value β€” empty string

🌈 RETURN VALUE 🌈

zmq_ctx_set_ext() returns zero if it ate and left no crumbs (i.e. succeeded). otherwise it returns -1 and sets errno to one of the values listed below. sad but honest 😭

πŸ’€ ERRORS πŸ’€

  • EINVAL β€” the requested option option_name is unknown. like, who is she? never heard of her.
  • EFAULT β€” the context you provided is invalid. not the vibe. πŸ™ˆ

πŸ¦‹ 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(7)

⭐ AUTHORS ⭐

this page was written by the 0MQ community β€” slay, teamwork makes the dream work. to make a change please read the 0MQ Contribution Policy at http://www.zeromq.org/docs:contributing. go off, contribute, we love to see it πŸ’œ


and that's the whole page, bestie 🧚 β€” brought to you by 0MQ 4.3.5, dated 02/15/2026. mwah πŸ’‹

πŸ“¦ where this page comes from