[zeromq-dev] Java to C++: junk appended to message?

Naveen Chawla naveen.chwl at gmail.com
Mon Aug 30 20:50:20 CEST 2010


And it works for any length of String, as long as I set the last byte
to 0. Thanks. (I misunderstood, thinking you meant 5 bytes isn't
valid, but 6 is).

Thanks again,
N

P.S. an additional "send" method in Java that takes a String and
converts it automatically before sending might be ok for Strings, but
I perhaps should have known this tidbit about strings anyway. Many
thanks again!

On 30 August 2010 19:39, Naveen Chawla <naveen.chwl at gmail.com> wrote:
> My apologies Pieter! I set the last byte to 0 in a six-character
> String and it worked.
>
> On 30 August 2010 19:02, Pieter Hintjens <ph at imatix.com> wrote:
>> On Mon, Aug 30, 2010 at 7:29 PM, Naveen Chawla <naveen.chwl at gmail.com> wrote:
>>
>>> C++ to C++ works fine. Message is only "[Hello]"
>>
>> You're sending five bytes, 'Hello', which is not a valid C string as
>> required by the printf function.  Either send six bytes (string plus 0
>> byte) or else convert the received message data to a valid string.
>>
>> I've wondered if 0MQ should not automatically and always append a null
>> byte to received messages (not included in stated message size) so
>> that strings can be safely passed between C/C++ and other languages.
>>
>> -
>> Pieter Hintjens
>> iMatix - www.imatix.com
>> _______________________________________________
>> zeromq-dev mailing list
>> zeromq-dev at lists.zeromq.org
>> http://lists.zeromq.org/mailman/listinfo/zeromq-dev
>>
>



More information about the zeromq-dev mailing list