Over the network, you could send the size of the message (which may be
zero) and then the message itself. See the example on this page
<https://developers.google.com/protocol-buffers/docs/reference/cpp/google.protobuf.io.coded_stream>
and
steaming multiple messages
<https://developers.google.com/protocol-buffers/docs/techniques#streaming>.

On Fri, Feb 5, 2021 at 1:26 PM Ivan Baidakou <[email protected]> wrote:

> Hi Nadav,
>
> I have to send the message over the network. If it returns the empty
> string, there is nothing to send. Anyway, I can see, that the remote side
> somehow sends (empty) Pings to me. How I can do the same?
>
>
> On Saturday, February 6, 2021 at 12:05:39 AM UTC+3 [email protected]
> wrote:
>
>> Hi Ivan,
>>
>> You are doing it correctly. An empty message has zero length when
>> serialized. This is also true for messages with only optional fields - an
>> empty array of bytes is a valid serialized instance of such a message.
>>
>> -Nadav
>>
>> On Fri, Feb 5, 2021 at 12:57 PM Ivan Baidakou <[email protected]> wrote:
>>
>>>
>>> Hi,
>>>
>>> There is a the following message type:
>>>
>>> message Ping {}
>>>
>>> When I invoke for my  object  "proto::Ping &ping" the ping.ByteSizeLong()
>>> it returns zero. ping.SerializeAsString() also returns empty string.
>>>
>>> What can be done?
>>>
>>> Thank you,
>>> wbr, basiliscos
>>>
>>> --
>>> 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 [email protected].
>>> To view this discussion on the web visit
>>> https://groups.google.com/d/msgid/protobuf/c5cfa7ca-bd7f-47b5-a993-0427b0e04d06n%40googlegroups.com
>>> <https://groups.google.com/d/msgid/protobuf/c5cfa7ca-bd7f-47b5-a993-0427b0e04d06n%40googlegroups.com?utm_medium=email&utm_source=footer>
>>> .
>>>
>>
>>
>> --
>> -Nadav
>>
> --
> 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 [email protected].
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/protobuf/4990bfa4-20a8-445b-b402-fbb134cde708n%40googlegroups.com
> <https://groups.google.com/d/msgid/protobuf/4990bfa4-20a8-445b-b402-fbb134cde708n%40googlegroups.com?utm_medium=email&utm_source=footer>
> .
>


-- 
-Nadav

-- 
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 [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/protobuf/CANZcNEqFp21Q_WpJ_eYJjjLmMz8%2BToLA9TXNv7z_PY4%2BreQ76Q%40mail.gmail.com.

Reply via email to