Re: [protobuf] [Java][Python][TCP] Reading messages that where written with writeDelimited and viceversa
On Tue, Sep 29, 2015 at 9:31 AM, Mike Whitewrote: > aloha everyone, > > i stumbled across this post as i'm hitting this error as well. since i'm a > newbie to python i had a question on how to implement this. when doing these > steps, > > # Read a message from Java's writeDelimitedTo: > import google.protobuf.internal.decoder as decoder buffer = open(sys.argv[1], "rb").read() > > # Read length > (size, position) = decoder._DecodeVarint(buffer, 0) > # Read the message > message_object.ParseFromString(buffer[position:position+size]) And then this should work, I think. -- 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/d/optout.
Re: [protobuf] [Java][Python][TCP] Reading messages that where written with writeDelimited and viceversa
On Mar 26, 2012, at 21:49 , Galileo Sanchez wrote: Thanks man... It worked great! I guess I should read the documentation a little more xP. Sadly these functions aren't actually documented. The Python API doesn't expose these routines for some reason I don't understand / remember. Glad it worked! Evan -- http://evanjones.ca/ -- You received this message because you are subscribed to the Google Groups Protocol Buffers group. To post to this group, send email to protobuf@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=en.
Re: [protobuf] [Java][Python][TCP] Reading messages that where written with writeDelimited and viceversa
On Mar 25, 2012, at 18:09 , Galileo Sanchez wrote: else if (Should I write the size as a raw bit string?) thenHow do I do that? You need to use something like the following. Not 100% sure it works but it should be close? Hope this helps, Evan # Output a message to be read with Java's parseDelimitedFrom import google.protobuf.internal.encoder as encoder out = message.SerializeToString() out = encoder._VarintBytes(len(out)) + out # Read a message from Java's writeDelimitedTo: import google.protobuf.internal.decoder as decoder # Read length (size, position) = decoder._DecodeVarint(buffer, 0) # Read the message message_object.ParseFromString(buffer[position:position+size]) -- http://evanjones.ca/ -- You received this message because you are subscribed to the Google Groups Protocol Buffers group. To post to this group, send email to protobuf@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=en.
Re: [protobuf] [Java][Python][TCP] Reading messages that where written with writeDelimited and viceversa
Thanks man... It worked great! I guess I should read the documentation a little more xP. On Monday, March 26, 2012 9:49:17 PM UTC-3, Evan Jones wrote: On Mar 25, 2012, at 18:09 , Galileo Sanchez wrote: else if (Should I write the size as a raw bit string?) thenHow do I do that? You need to use something like the following. Not 100% sure it works but it should be close? Hope this helps, Evan # Output a message to be read with Java's parseDelimitedFrom import google.protobuf.internal.encoder as encoder out = message.SerializeToString() out = encoder._VarintBytes(len(out)) + out # Read a message from Java's writeDelimitedTo: import google.protobuf.internal.decoder as decoder # Read length (size, position) = decoder._DecodeVarint(buffer, 0) # Read the message message_object.ParseFromString(buffer[position:position+size]) -- http://evanjones.ca/ -- You received this message because you are subscribed to the Google Groups Protocol Buffers group. To view this discussion on the web visit https://groups.google.com/d/msg/protobuf/-/GDPoYpNMZl4J. To post to this group, send email to protobuf@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=en.