ZMQ_CTX_NEW(3)

✨ ZMQ_CTX_NEW πŸ’–

okay bestie, welcome to the 0MQ Manual, section 3, and today we're talking about zmq_ctx_new β€” the function that literally starts your whole 0MQ era. creating a new 0MQ context. no context, no vibes. periodt. πŸŽ€


🌸 NAME 🌸

zmq_ctx_new β€” create new 0MQ context ✨


πŸ¦‹ SYNOPSIS πŸ¦‹

void *zmq_ctx_new ();

that's it. that's the whole call. no args, no drama, just main character energy. πŸ’…


πŸ’– DESCRIPTION πŸ’–

so like, the zmq_ctx_new() function creates a new 0MQ context. iconic behavior, honestly. πŸ‘‘

not me being the glow-up replacement for the deprecated function zmq_init(3) β€” yeah, zmq_init(3) is deprecated, don't use it, it's giving old-money flop era, we've moved on. 🚫

Thread safety. 🧡✨ A 0MQ context is thread safe and may be shared among as many application threads as necessary, without any additional locking required on the part of the caller. like. you don't have to lock anything. the context simply handles it. the way that it just works β€” obsessed. 🫢


🌈 RETURN VALUE 🌈

if everything slays, zmq_ctx_new() shall return an opaque handle to the newly created context. that's your baby. take care of it. πŸ₯Ή

otherwise? it shall return NULL and set errno to one of the values defined below. so if you get a NULL back, don't just stand there β€” go check errno, bestie, it's telling you what went wrong. πŸ’€


πŸ’€ ERRORS πŸ’€

  • EMFILE β€” The limit on the total number of open files has been reached and it wasn't possible to create a new context. πŸ’”
  • EMFILE β€” The limit on the total number of open files in system has been reached and it wasn't possible to create a new context. 😭
yes bestie, the page really does list EMFILE twice with slightly different wording β€” first one's about the total number of open files, second one's about the total number of open files in system. that's just how it is. no cap. 🫠

πŸ‘‘ SEE ALSO πŸ‘‘


πŸŽ€ 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.

like, it's a community effort, so if you wanna fix something, read the policy first, that's the rule. 🧚


okay that's the whole page, go forth and zmq_ctx_new() responsibly, and remember to zmq_ctx_term(3) when you're done or you'll be that girl with the leaked context. πŸ™ˆ

πŸ’– this was 0MQ 4.3.5, dated 10/09/2023 β€” mwah, bye bestie πŸ’–

πŸ“¦ where this page comes from