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

KIU Shueng Chuan nixchuan at gmail.com
Sat Dec 12 22:57:41 CET 2015


The type of that socket option was changed to "int" since version 3.2.x

Rather than extracting the more flag using getsockopt, you can also do:

int more = zmq_msg_more (&part);
On 13 Dec 2015 03:01, "Jeff Shanab" <jshanab at jfs-tech.com> wrote:

> 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.
>
>
>
>
>
>
> _______________________________________________
> zeromq-dev mailing list
> zeromq-dev at lists.zeromq.org
> http://lists.zeromq.org/mailman/listinfo/zeromq-dev
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.zeromq.org/pipermail/zeromq-dev/attachments/20151213/db1461f6/attachment.htm>


More information about the zeromq-dev mailing list