2

Does Cap'n Proto support delimited messages?

My goal is to write multiple messages to a file pipe and read in real-time as they are being written.

So...

  1. The messages need to be delimited in some way.

  2. And the parser must be able to detect incomplete messages and wait.

Drew Dormann
  • 59,987
  • 13
  • 123
  • 180
BAR
  • 15,909
  • 27
  • 97
  • 185

2 Answers2

5

Yes. Unlike Protocol Buffers, Cap'n Proto messages are inherently self-delimiting. If you use the standard serialization functions to repeatedly write messages to the same stream, or repeatedly read messages from the same stream, it will "just work". Make sure to use the serialization / parsing routines that write to / read from a stream (in C++ you can use a file descriptor or an abstract InputStream/OutputStream), so that the parser knows how to wait for input. There are also asynchronous (non-blocking) versions of these if you prefer an event-driven approach.

Kenton Varda
  • 41,353
  • 8
  • 121
  • 105
  • Thanks Kenton. While trying to test this out I ran across this error in C++ http://stackoverflow.com/questions/31978684/error-while-loading-shared-libraries-libcapnp-0-5-3-so Maybe you can help? – BAR Aug 13 '15 at 02:48
0

Cap'n'Proto is not meant as a stream parser, though you could use it as such (by treating your message as a sequence of either Text or Data blocks (depending on your exact use case).

llogiq
  • 13,815
  • 8
  • 40
  • 72