[zeromq-dev] 64bit Issue discovered with zmq_getsockopt(..., ZMQ_RCVMORE, ...

Jeff Shanab jshanab at jfs-tech.com
Sat Dec 12 20:01:28 CET 2015

Using ZMQ 4.0.4 on windows 64bit in Visual studio with a simple REQ-REP
with multipart messages.

All examples and guide show code like

int64_t more;
size_t more_size = sizeof more;
do {
 /* Create an empty ØMQ message to hold the message part */
 zmq_msg_t 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 (&part, socket, 0);
 assert (rc != -1);
 /* Determine if more message parts are to follow */
 rc = zmq_getsockopt (socket, ZMQ_RCVMORE, &more, &more_size);
 assert (rc == 0);
 zmq_msg_close (&part); } while (more);

I found that the value of more is a ridiculously large negative integer
and fails to detect the last frame unless I initialize it to zero.

(note Debug in GCC zeros memory, Visual Studio does not.)

Inspection of the value in hex may reveal a 64 bit porting problem,

The values is 0xCCCCCCCC00000000

Which is setting it to a int const without the ull specifier ????

Anyway I change "int64_t more;" to "int64_t more = 0;" and operation
is restored.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.zeromq.org/pipermail/zeromq-dev/attachments/20151212/da2d29f5/attachment.htm>

More information about the zeromq-dev mailing list