[protobuf] How to serialize/deserialize bytes data?

2016-12-22 Thread song1219
I defined a simple bytes message below
message MfStream {
  bytes message=1;
}

and run a test below, in which I use for a loop to keep 
serialize/deserialize the bytes message.

char buf[1024];
int tmp = 1;
MfStream testMsg;
testMsg.set_message(, sizeof(tmp));
for (int i=0; i<5; i++) {
int size = testMsg.ByteSize();
testMsg.SerializeToArray(buf, sizeof(buf));
cout << "i=" << i << ", size=" << size << endl;
testMsg.set_message(buf, size);
}


The results below shows that the message size keeps increasing by 2 every 
loop. Why? How should I serialize/deserialize bytes data?

i=0, size=6
i=1, size=8
i=2, size=10
i=3, size=12
i=4, size=14

-- 
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 https://groups.google.com/group/protobuf.
For more options, visit https://groups.google.com/d/optout.


Re: [protobuf] Async RPC methods in protobuf?

2016-11-15 Thread song1219
Yes, I agree with you that it is all dependent on the generated code. So 
does protobuf compiler provide the option to generate async APIs? If not, 
how complicated will it be to modify the complier?

On Tuesday, November 15, 2016 at 5:11:36 PM UTC-8, Feng Xiao wrote:
>
>
>
> On Tue, Nov 15, 2016 at 4:37 PM,  
> wrote:
>
>> Thanks for the reply. I am not using gRPC. I want to use protobuf to 
>> define RPC, but have a separate or customized transport implementation.
>>
> There is no such thing as sync vs. async API in proto definition. It's 
> only relevant in the generated service API. For example, given:
> service HelloService {
>   rpc Hello(Request) returns (Response);
> }
>  
> You can generate code that provides sync API, or generate code that 
> provides async API:
> class HelloService {
>  public:
>   void Hello(const Request& request, const std::function Response&)>& result_callback);
> }
>
>
>>
>> On Tuesday, November 15, 2016 at 4:30:12 PM UTC-8, Feng Xiao wrote:
>>>
>>> Are you using grpc? You can post grpc related questions to 
>>> https://groups.google.com/forum/#!forum/grpc-io
>>>
>>> On Tue, Nov 15, 2016 at 4:03 PM,  wrote:
>>>
 I notice that when RPC methods are defined in a proto file, they are 
 all sync APIs. Is there a way to define async methods? Thanks.

 -- 
 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+u...@googlegroups.com.
 To post to this group, send email to prot...@googlegroups.com.
 Visit this group at https://groups.google.com/group/protobuf.
 For more options, visit https://groups.google.com/d/optout.

>>>
>>> -- 
>> 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+u...@googlegroups.com .
>> To post to this group, send email to prot...@googlegroups.com 
>> .
>> Visit this group at https://groups.google.com/group/protobuf.
>> For more options, visit https://groups.google.com/d/optout.
>>
>
>

-- 
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 https://groups.google.com/group/protobuf.
For more options, visit https://groups.google.com/d/optout.


Re: [protobuf] Async RPC methods in protobuf?

2016-11-15 Thread song1219
Thanks for the reply. I am not using gRPC. I want to use protobuf to define 
RPC, but have a separate or customized transport implementation.

On Tuesday, November 15, 2016 at 4:30:12 PM UTC-8, Feng Xiao wrote:
>
> Are you using grpc? You can post grpc related questions to 
> https://groups.google.com/forum/#!forum/grpc-io
>
> On Tue, Nov 15, 2016 at 4:03 PM,  
> wrote:
>
>> I notice that when RPC methods are defined in a proto file, they are all 
>> sync APIs. Is there a way to define async methods? Thanks.
>>
>> -- 
>> 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+u...@googlegroups.com .
>> To post to this group, send email to prot...@googlegroups.com 
>> .
>> Visit this group at https://groups.google.com/group/protobuf.
>> For more options, visit https://groups.google.com/d/optout.
>>
>
>

-- 
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 https://groups.google.com/group/protobuf.
For more options, visit https://groups.google.com/d/optout.


[protobuf] Async RPC methods for protobuf?

2016-11-15 Thread song1219
I notice that when RPC methods are defined in .proto file. They are all 
sync APIs. Is there way to define async APIs? Thanks!

-- 
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 https://groups.google.com/group/protobuf.
For more options, visit https://groups.google.com/d/optout.


[protobuf] test

2016-11-15 Thread song1219
test post

-- 
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 https://groups.google.com/group/protobuf.
For more options, visit https://groups.google.com/d/optout.


[protobuf] Trest

2016-11-15 Thread song1219
test

-- 
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 https://groups.google.com/group/protobuf.
For more options, visit https://groups.google.com/d/optout.


[protobuf] Async RPC methods in protobuf?

2016-11-15 Thread song1219
I notice that when RPC methods are defined in a proto file, they are all 
sync APIs. Is there a way to define async methods? Thanks.

-- 
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 https://groups.google.com/group/protobuf.
For more options, visit https://groups.google.com/d/optout.