[ndnSIM] How to add a new variable
aa at CS.UCLA.EDU
Fri Feb 10 20:37:20 PST 2017
> On Feb 10, 2017, at 7:30 PM, 呂建德 <v0918732669 at gmail.com> wrote:
> I test the same code on three platfoms like below.
> http://imgur.com/a/9e38l <http://imgur.com/a/9e38l>
> and the first one is mac os, second one is mint based on ubuntu16.04, the last one is ubuntu16.04 LTS.
> the code in ndn-producer is
> data->setContent(::ndn::encoding::makeStringBlock(::ndn::tlv::Content, str));
> the code in ndn-consumer is
> NS_LOG_INFO("< DATA for " << data->getContent().value());
This is not the proper way of interpreting content as a string. This will try to interpret bytes carried in the content as a null-terminated string, which the content probably isn't.
Use this, a bit more explicit, way:
std::string stringValue(data->getContent().value(), data->getContent().value_size());
> I dont know what happened on these platforms, the same code ,the different result. orz
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the ndnSIM