1

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!

1
  • 1
    byte[] is the only data-type that can be sent directly to a stream. Why serialize at all ? Commented Aug 5, 2012 at 15:32

2 Answers 2

1

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.

Sign up to request clarification or add additional context in comments.

2 Comments

Ah, right sorry. I misunderstood what protobuf-net does. Is there any compression libraries that you would recommend besides GZipStream?
@Joey DeflateStream? #ZipLib provides a handful of compression implementations.
0

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.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.