Is it possible to serialize a byte array using protobuf-net and then send it over a socket for de-serializing client side? I’m looking for an efficient way to compress/reduce the data which is sent. Somebody told me protobuf-net would be the best way. Any idea how I would go about it?
Thanks for the help!
Protobuf-net is a serializer, intended for reducing complex object structures to a basic representation that can be sent over a wire. It does not use compression. If you want compression, using something like GZipStream. Indeed, the protobuf representation of a byte[] is: the length of the data (as a varint) followed by the original byte[]. No protobuf implementation will reduce that.
So: either send the original byte[] “as is”, or use something like GZipStream to try to reduce the size. Note that this is not always possible, and for some data compression tools can increase the size.