ZMQ_MSG_MORE(3)

πŸ’– ZMQ_MSG_MORE(3) πŸ’–

okay bestie, pull up a chair, because we're doing a whole deep dive into zmq_msg_more from the 0MQ Manual and honestly? it's giving tiny-but-mighty. ✨


🌸 NAME 🌸

zmq_msg_more β€” tell you if there are more message parts left to receive πŸŽ€


πŸ¦‹ SYNOPSIS πŸ¦‹

int zmq_msg_more (zmq_msg_t *message);

✨ DESCRIPTION ✨

so the zmq_msg_more() function is your little gossip source β€” it tells you whether this message is part of a multi-part message, and whether there are further parts still waiting to be received. πŸ‘€

and here's the slay part: this method can safely be called after zmq_msg_close(). no cap. it doesn't care, it's still gonna answer you. πŸ’…

also fun fact, this method is identical to zmq_msg_get() with an argument of ZMQ_MORE. same vibe, different name. iykyk. 🫢


🌈 RETURN VALUE 🌈

  • returns zero if this is the final part of a multi-part message, or if it's the only part of a single-part message πŸ“
  • returns 1 if there are further parts to receive πŸ”₯

πŸ’œ EXAMPLE πŸ’œ

here's us receiving a multi-part message, main character energy only:

zmq_msg_t part;
while (true) {
    //  Create an empty 0MQ message to hold the message part
    int rc = zmq_msg_init (&part);
    assert (rc == 0);
    //  Block until a message is available to be received from socket
    rc = zmq_msg_recv (socket, &part, 0);
    assert (rc != -1);
    if (zmq_msg_more (&part))
        fprintf (stderr, "more\n");
    else {
        fprintf (stderr, "end\n");
        break;
    }
    zmq_msg_close (&part);
}

look at that loop just vibing until it hits the end. iconic. 😭


πŸ‘‘ SEE ALSO πŸ‘‘


🧚 AUTHORS 🧚

this page was written by the 0MQ community. πŸ’– if you wanna make a change, please read the 0MQ Contribution Policy at http://www.zeromq.org/docs:contributing. bestie behavior fr fr.


and that's the whole page, periodt. this little gem came to you from 0MQ 4.3.5, dated 10/09/2023, filed under ZMQ_MSG_MORE(3). mwah, go forth and check your message parts πŸ’…πŸŽ€πŸ¦‹βœ¨

πŸ“¦ where this page comes from