If you use Builder.mergeFrom() and catch the exception, the builder will be
left containing whatever data was parsed before the problem was detected.

However, a better solution would be to encode your data in multiple
messages, such that each packet you send contains one message.  That way, if
one packet is lost, it doesn't prevent you from parsing previous or
subsequent packets.  You can also receive packets out-of-order.

On Fri, Nov 20, 2009 at 8:50 AM, ecl <elot...@gmail.com> wrote:

> I have a protocol buffer where I'm encoding audio snippets, containing
> a small header, and a few hundred kilobytes of (mono or stereo,
> multiplexed or not) audio data, as bytes. However, due to the nature
> of the intermittent communications, the message may get truncated at
> some point, most probably past the header, but therefore truncating a
> significant chunk of the audio bytes.
>
> As even the initial part of the audio could be useful (if the
> remaining bits gets lost) - is there a way to safely deserialize a
> protocol buffer message where the end has been chopped off? I've
> tested deserializing a message where the last byte was removed - this
> causes an exception (using the Java API), and apparently no way to get
> the partial message, and most importantly, the partial bytes.
>
> Any ideas on how I could go to solve this problem?
>
> Kind regards,
> Ernest
>
> --
>
> You received this message because you are subscribed to the Google Groups
> "Protocol Buffers" group.
> To post to this group, send email to proto...@googlegroups.com.
> To unsubscribe from this group, send email to
> protobuf+unsubscr...@googlegroups.com<protobuf%2bunsubscr...@googlegroups.com>
> .
> For more options, visit this group at
> http://groups.google.com/group/protobuf?hl=.
>
>
>

--

You received this message because you are subscribed to the Google Groups 
"Protocol Buffers" group.
To post to this group, send email to proto...@googlegroups.com.
To unsubscribe from this group, send email to 
protobuf+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/protobuf?hl=.


Reply via email to