n***@gmail.com
2018-06-14 14:21:40 UTC
HI,
Using capnproto-c++-0.6.1 I am trying to serialize a Capnp message to
bytes to send over a multicast socket. I am getting an error when trying to
deserialize.
Here is what I am trying to do.
auto flatArray = capnp::messageToFlatArray(message);
std::cout << "flatArray size : " << flatArray.size() << std::endl; //
flatArray size : 17
auto bytesToSend = capnp::messageToFlatArray(message).asBytes();
std::cout << "bytesToSend size : " << bytesToSend.size() << std::endl; //
bytesToSend size : 136
// The following works fine
capnp::FlatArrayMessageReader msg(flatArray);
// But the following throws an exception: capnp/serialize.c++:43: failed:
expected array.size() >= offset; Message ends prematurely in segment table.
char result[bytesToSend.size()]; // what i would like to write to my UDP
socket
auto words = kj::heapArray<capnp::word>(bytesToSend.size()/ sizeof(capnp::
word));
std::cout << "words size : " << words.size() << std::endl; // words size :
17 (as expected)
memcpy(words.begin(), &result, bytesToSend.size());
capnp::FlatArrayMessageReader msg(words); // Exception!!
Note - this is similar to this previous topic :
https://groups.google.com/forum/#!topic/capnproto/OcYhwDfB4vE but the
comments there didn't get me going.
Thank you very much for your time.
Using capnproto-c++-0.6.1 I am trying to serialize a Capnp message to
bytes to send over a multicast socket. I am getting an error when trying to
deserialize.
Here is what I am trying to do.
auto flatArray = capnp::messageToFlatArray(message);
std::cout << "flatArray size : " << flatArray.size() << std::endl; //
flatArray size : 17
auto bytesToSend = capnp::messageToFlatArray(message).asBytes();
std::cout << "bytesToSend size : " << bytesToSend.size() << std::endl; //
bytesToSend size : 136
// The following works fine
capnp::FlatArrayMessageReader msg(flatArray);
// But the following throws an exception: capnp/serialize.c++:43: failed:
expected array.size() >= offset; Message ends prematurely in segment table.
char result[bytesToSend.size()]; // what i would like to write to my UDP
socket
auto words = kj::heapArray<capnp::word>(bytesToSend.size()/ sizeof(capnp::
word));
std::cout << "words size : " << words.size() << std::endl; // words size :
17 (as expected)
memcpy(words.begin(), &result, bytesToSend.size());
capnp::FlatArrayMessageReader msg(words); // Exception!!
Note - this is similar to this previous topic :
https://groups.google.com/forum/#!topic/capnproto/OcYhwDfB4vE but the
comments there didn't get me going.
Thank you very much for your time.
--
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+***@googlegroups.com.
Visit this group at https://groups.google.com/group/capnproto.
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+***@googlegroups.com.
Visit this group at https://groups.google.com/group/capnproto.