ØMQ Manual - ØMQ/3.1.0


zmq_getmsgopt - retrieve message option


int zmq_getmsgopt (zmq_msg_t *message, int option_name, void *option_value, size_t *option_len);


The zmq_getmsgopt() function shall retrieve the value for the option specified by the option_name argument for the message pointed to by the message argument, and store it in the buffer pointed to by the option_value argument. The option_len argument is the size in bytes of the buffer pointed to by option_value; upon successful completion zmq_getsockopt() shall modify the option_len argument to indicate the actual size of the option value stored in the buffer.

The following options can be retrieved with the zmq_getmsgopt() function:

Indicates that there are more message parts to follow after the message.

Return value

The zmq_getmsgopt() function shall return zero if successful. Otherwise it shall return -1 and set errno to one of the values defined below.


The requested option option_name is unknown, or the requested option_size or option_value is invalid, or the size of the buffer pointed to by option_value, as specified by option_len, is insufficient for storing the option value.


Receiving a multi-part message

zmq_msg_t part;
int more;
size_t more_size = sizeof (more);
while (true) {
    /* Create an empty ØMQ 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_recvmsg (socket, &part, 0);
    assert (rc != -1);
    rc = getmsgopt (&part, ZMQ_MORE, &more, &more_size);
    assert (rc == 0);
    if (more) {
      fprintf (stderr, "more\n");
    else {
      fprintf (stderr, "end\n");
    zmq_msg_close (part); }

See also

zmq_msg_data(3) zmq_msg_init(3) zmq_msg_init_size(3) zmq_msg_init_data(3) zmq_msg_close(3) zmq(7)


The ØMQ documentation was written by Chuck Remes <||semerc>.