Reputation: 26581
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!
Upvotes: 1
Views: 3329
Reputation: 21
We got great improvements by using the LZMA SDK from 7Zip (http://www.7-zip.org/sdk.html) to compress/decompress the byte array representation of our protobuf'ed objects. For exemple, an array of 1114 bytes shrunk to 740. But like Marc said, your mileage may vary.
Upvotes: 0
Reputation: 1062780
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.
Upvotes: 1