Customizing segment size

21 views
Skip to first unread message

Perplumblewintz Jönz

unread,
Mar 23, 2020, 1:41:20 AM3/23/20
to Cap'n Proto
I am trying to send Cap'n Proto messages across a proprietary 3rd-party communication channel, which is limited to sending and receiving 100 bytes at a time.  I was hoping to send each segment as a ZeroMQ multipart message part, but I would need to ensure that each segment is less than 100 bytes.  Again, I was hopeful that packing could help ensure this, but I'm not clear that this is true after some time reading the code.  It seems that I might need to adjust the segment size, but data alignment and such is not something that I've dealt with before and is currently beyond me.

Can anyone confirm that this should work or possibly suggest an alternative approach?

Thanks!

Kenton Varda

unread,
Mar 23, 2020, 1:21:47 PM3/23/20
to Perplumblewintz Jönz, Cap'n Proto
Hi Perplumblewintz,

While technically you could try to customize segment size using a custom MessageBuilder subclass, I don't think it's going to work very well for such tight constraints. Instead, I'd suggest you serialize the whole message into a byte buffer upfront, apply any compression (whether that be packed mode or a real compression algorithm like zstd), then split the final buffer into 100-byte chunks. Then reassemble on the other side before parsing.

-Kenton

--
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.
To view this discussion on the web visit https://groups.google.com/d/msgid/capnproto/8291c8d3-db05-43bc-8551-223625059bd4%40googlegroups.com.
Reply all
Reply to author
Forward
0 new messages