So this seems trivial but I've been at it for a while and am not making
much headway so I'm clearly have some fundamental misunderstanding. I'm
trying to use raw sockets to send and receive messages, standard berkeley
sockets. Here's what I have so far:
server:
::capnp::MallocMessageBuilder builder;
auto mydata = builder.initRoot<MY_TYPE>();
mydata.setField1(...
...
capnp::writeMessageToFd(sockfd, builder);
client:
::capnp::MallocMessageBuilder builder;
capnp::readMessageCopyFromFd(sockfd, builder);
auto data = messageBuilder.getSegmentsForOutput();
for(const auto& datum : data) {
capnp::FlatArrayMessageReader reader(datum); //throws error here
MY_TYPE::Reader dataReader = reader.getRoot<MY_TYPE>();
//do stuff with the data...
}
The run-time error I get when trying to deserialize the data using the
FlatArrayMessageReader class is:
terminate called after throwing an instance of 'kj::ExceptionImpl'
what(): src/capnp/serialize.c++:56: failed: expected array.size() >=
offset + segmentSize; Message ends prematurely in first segment.
It looks like some bounds check is failing, but I have no idea why or how
to fix it. Any comments on my code or more effective strategies to do what
I'm trying to do are greatly appreciated. It seems to be the
deserialization part that greatly confuses me and I can't figure out, but
my serialization/server side code could be wrong also.
--
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 [email protected].
Visit this group at https://groups.google.com/group/capnproto.