If this is important for you, you can add a transport layer that has
framing; video transports usually do this to allow re sync of a stream with
bad data, and there are other similar transports.
You could also look at erasure coding but it might be overkill...
On 14 Apr 2017 15:08, "'Kenton
Thanks for the reply. Option 1 seems pretty reasonable for me. I would
probably go as far as to frame the messages with magic + message size, that
way I can verify that when there's another magic (or end of file) at
current position + message size It's probably correct.
On Friday, April 14,
Hi Stepan,
No, there's no easy way to detect the corruption your describe. In fact,
for most serialization formats, there's no solution to this problem. Once
you've lost track of message boundaries, it's impossible to tell the
difference between the start of a new message vs. data in the previous
I have a message that serializes into 24 bytes. I write two messages to a
file resulting in a file thats 48 bytes long. Now I truncate the file to 40
bytes and write one message, so the file now looks like this: 1 full
message, one broken, 1 full message. Is there any way to iterate over the