开发者

Which serialization for sending protobuf via sockets in C++?

开发者 https://www.devze.com 2023-02-25 09:55 出处:网络
Which kind of serialization is the most meaningful when sending serialized protobuf data via开发者_开发知识库 socket in C++? I use boost sockets.

Which kind of serialization is the most meaningful when sending serialized protobuf data via开发者_开发知识库 socket in C++? I use boost sockets.

Until now, I sent std::strings via sockets. I have the option to serialize the protobuf objects into a string and send this string via socket.

Is this slow or slower compared to the other serialization types offered by protobuf?


No. All the serialization methods generate identical output using an identical algorithm. The only savings you are going to have is in time memcpy-ing the data and perhaps the amount of memory used. For all reasonably sized protocol buffers, this is negligible.

In general, you should pick the serialization method that makes your code most readable.

0

精彩评论

暂无评论...
验证码 换一张
取 消