ZMQ_MSG_CLOSE(3)

πŸ’– ZMQ_MSG_CLOSE(3) πŸ’–

okay bestie, welcome to the zmq_msg_close page from the 0MQ manual β€” this is the one where you say bye-bye to a message and free up its lil resources. it's giving closure, literally. ✨


🌸 NAME 🌸

zmq_msg_close β€” release a 0MQ message 🫢


✨ SYNOPSIS ✨

int zmq_msg_close (zmq_msg_t *msg);

πŸ¦‹ DESCRIPTION πŸ¦‹

So here's the tea: zmq_msg_close() tells the 0MQ infrastructure that any resources tied to the message object that msg points at are no longer needed and can be released. πŸ’…

but WAIT β€” and this is the part everyone skips β€” the actual freeing of those resources gets postponed by 0MQ until all users of the message or of the underlying data buffer have said they're done with it. it's not a "drop it the second you ask" situation, it's a "we'll handle it when everyone's out of the group chat" situation. 🌈

applications should make sure zmq_msg_close() gets called once a message is no longer required, otherwise memory leaks may occur 😭. that's the scary part. don't leak, bestie.

lowkey important: this is NOT necessary after a successful zmq_msg_send(). the send already handled it, you don't need to double up. periodt.
⚠️ Caution ⚠️ Never access zmq_msg_t members directly. like, ever. instead, always use the zmq_msg family of functions. iykyk. πŸ™ˆ

πŸŽ€ RETURN VALUE πŸŽ€

  • zero β€” slay, it worked, the function was successful πŸ’–
  • -1 β€” not slay. and it sets errno to one of the values listed down below πŸ‘‡

πŸ’€ ERRORS πŸ’€

  • EFAULT β€” invalid message. that's it, that's the whole error. the message you handed over was not it. πŸ™ˆ

πŸ‘‘ SEE ALSO πŸ‘‘

zmq_msg_init(3) zmq_msg_init_size(3) zmq_msg_init_buffer(3) zmq_msg_init_data(3) zmq_msg_data(3) zmq_msg_size(3) zmq(7)


🧚 AUTHORS 🧚

this page was written by the 0MQ community 🫢 and honestly, iconic of them. if you wanna make a change, go read the 0MQ Contribution Policy at http://www.zeromq.org/docs:contributing β€” the link is right there, bestie, no excuses. πŸ’…


and that's the whole vibe check, babe. this was the 0MQ 4.3.5 manual, dated 10/09/2023 β€” go close those messages responsibly and hydrate. mwah. πŸ’–βœ¨πŸŽ€

πŸ“¦ where this page comes from