2
votes

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?

1
@Marc Gravell to send a string, the protobuf objects are serialized to a string which is send via socket.Konrad Reiche
I can't speak directly about the C++ version (as I'm C# focused), but my expectation is that sending direct to the stream-based approach should be more efficient. If nobody C++ familiar stops by, you might have to profile, though.Marc Gravell

1 Answers

2
votes

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.