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

Jeff Shanab jshanab at jfs-tech.com
Sat Dec 12 23:07:24 CET 2015


It took a bit of time to find out the guide led me down the wrong path.
:-(
If it doesn't work, it really shouldn't be the suggested code in the
guide.

On Sat, Dec 12, 2015 at 4:57 PM, KIU Shueng Chuan <nixchuan at gmail.com>
wrote:

> 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
>>
>>
> _______________________________________________
> 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/20151212/f56ef59f/attachment.htm>


More information about the zeromq-dev mailing list