[zeromq-dev] help: memcpy with message_t

liuchuanbo at gmail.com liuchuanbo at gmail.com
Tue Aug 6 16:41:35 CEST 2013


Hi, Admir

Thanks. 
You're right.

zipcode.data() is also correct.

--
Best Regards,
Roy Liu

On 2013-8-6, at 下午9:58, Admir Efendic <admir.efendic at gmail.com> wrote:

> been ages but shouldn't this work:
> 
> memcpy ((void *) message.data(), zipcode.c_str(), zipcode.size()+1);
> 
> 
> 
> 2013/8/6 <liuchuanbo at gmail.com>
> I'm using PUB-SUB test with zmq.
> pls give me some advices. Thanks.
> 
> 
> My code:
> ---------------------
> std::string zipcode = "10001";
> zmq::message_t message(zipcode.size()+1);
> 
> // it's OK.
> memcpy ((void *) message.data(), "10001", zipcode.size()+1);
> 
> // it's Error, subscriber always receives bizarre code.
> memcpy ((void *) message.data(), &zipcode, zipcode.size()+1);
> ---------------------
> 
> 
> 
> --
> Best Regards,
> Roy Liu
> 
> 
> _______________________________________________
> 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/20130806/9eba0c85/attachment.htm>


More information about the zeromq-dev mailing list