what API to get bytes data back

23 views
Skip to first unread message

song...@hotmail.com

unread,
Dec 22, 2016, 1:34:10 PM12/22/16
to grpc.io
I defined a simple message below
message MfStream {
  bytes message=1;
}

After calling msg.set_message(), code shown below, I serialized msg and noticed the msg have two more bytes than the (buf and len). What is the API I can use to serialize to the original buf and len? Look forward to your reply. Thanks.


char* buf;
int len;
...
...
MfStream msg;
msg.set_message(buf, len);


Masood Malekghassemi

unread,
Dec 28, 2016, 1:21:51 PM12/28/16
to grpc.io, song...@hotmail.com
This is a protobuf question and would be better served on that project's lists.

Having said that, unless you're having trouble deserializing the message to retrieve the original bytes, I wouldn't fret over the serialized size of `msg` itself (assuming that's what you were referring to when you said 'msg have two more bytes') being a smidgen larger than its contents. If you're using protobuf 3.x (the major version family that gRPC uses), your fields will be automatically 'optional' (in protobuf 2.x parlance), for example, and their presence/absence thus needs to be noted in the serialization somehow.
Reply all
Reply to author
Forward
0 new messages