I am writing multiple protobuf messages to a file in C++.
int fifoPipe = open("/media/my_pipe", O_WRONLY);
MyModel *model = new MyModel();
// Write to fifo pipe.
model->SerializeToFileDescriptor(fifoPipe);
I had read that the message size is written to the file automatically before the message data. Apparently this is not the case:
https://developers.google.com/protocol-buffers/docs/techniques?hl=en
So in Java it should be possible to read the message like so:
MyModel.parseDelimitedFrom(fileInputStream);
However there are questions here:
Cannot deserialize protobuf data from C++ in Java
Are there C++ equivalents for the Protocol Buffers delimited I/O functions in Java?
That say the message size must be written manually.
Since the questions are kind of old this procedure may have changed.
What is the proper way of writing multiple messages in C++ and reading those messages in Java?
Also consider how Java would respond to a half written message. In theory it should wait for data the size of message size to be present before returning.