On Wed, Jul 24, 2013 at 12:27 AM, Andreas Reuter <
andreas.rou...@googlemail.com> wrote:

> Hello,
>
> we are using Protobuf to communicate between two devices via Ad-hoc WiFi.
> One of the devices is running a Java application and the other a Python
> application.
>

[...]


> 6. Upon closer inspection, we saw that the parser seems to be doing
> alright, successfully assembling the packet message. However the message is
> only  a few bytes long, and after that the
> parser just keeps reading the byte array(buffer, which is 128 byte long).
> The byte array is filled with 0's. Upon reading a 0 the exception occurs.
>

Protobuf messages are not self-delimiting; you must provide some other
mechanism yourself to find the end of the message.
The common way is to prefix the message with a length field - see
https://developers.google.com/protocol-buffers/docs/techniques#streaming
Or if there is no other data in the UDP datagram you could just use the
datagram length directly (i.e. get rid of the trailing garbage - why are
you padding the datagram in the first place?)

Oliver

-- 
You received this message because you are subscribed to the Google Groups 
"Protocol Buffers" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to protobuf+unsubscr...@googlegroups.com.
To post to this group, send email to protobuf@googlegroups.com.
Visit this group at http://groups.google.com/group/protobuf.
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to