Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Recommendations for .NET compression library [closed]

Tags:

I am looking for some recommendations about compressing data in .NET, aside from using the GZipStream class.

I am looking for fast and high compression of byte arrays to be able to send them via TCP.

like image 636
G-Man Avatar asked Jun 15 '10 15:06

G-Man


1 Answers

If you are compressing data, then you might look at high-density serialization, rather than compression. Something like protobuf. There are a few C# implementations here. For existing objects, protobuf-net is IMO the simplest to implement (disclosure: I'm the author - but it is free etc). You just serialize to the stream, or if you want a byte[], a separate MemoryStream.

For continuous use over a socket (rather than the discreet request/response of HTTP), I would suggest looking at the Serializer.SerializeWithLengthPrefix / Serializer.DeserializeWithLengthPrefix operations (protobuf doesn't itself include a terminator, so a length-prefix is necessary to handle separate messages).

like image 108
Marc Gravell Avatar answered Sep 29 '22 20:09

Marc Gravell