I'm trying to debug my problem. My sending side I can see the number of 
bytes which results in 55 from:

    bytes.size()
    
And the receiving side I can see it received the same number of bytes, 55.

    len    
    
Is there a shortcut way to print the contents of what was received. Some 
way to print the sending side serialized data of words.asBytes() and the 
receiving serialized data, words?

I feel like the error of not containing a root pointer means it's not 
finding/reading the serialized data somehow correctly.

On Thursday, March 10, 2022 at 7:14:42 PM UTC-6 William Zumwalt wrote:

> Hello,
> I am getting the following error.
>
> Exception in setting up a receiver: capnp/message.c++:99: failed: expected 
> setment != nullptr && segment->checkObject(segment->getStartPtr(), ONE * 
> WORDS); Message did not contain a root pointer.
>
> Here is how I send a byte array.
>
>     auto msg_builder = builder.initRoot<SomeMsg>();
>     msg_builder.setVal(val);
>     
>     auto words = messageToFlatArray(msg_builder);
>     auto bytes = words.asBytes();
>     
>     peer.send(bytes);
>     
> And then receive it on the other end.
>     string msg;
>     peer.get(msg);
>
>     MallocMessageBuilder builder;
>     const void* arr = msg.c_str();
>     int len = msg.size();
>     
>     auto words = kj::heapArray<capnp::word>(len / sizeof(capnp::word));
>     memcpy(words.begin(), arr, len);
>     
>     FlatArrayMessageReader reader(words);
>     
>     // error happens on this call
>     auto m = reader.getRoot<SomeMsg>();
>     
> Any thoughts/hints at what's wrong? Thanks
>     

-- 
You received this message because you are subscribed to the Google Groups 
"Cap'n Proto" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to capnproto+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/capnproto/075e066d-81c9-4268-9e4f-939e11a62a59n%40googlegroups.com.

Reply via email to