Good zlib implementation in .NET?

I am creating a network application that should be able to switch from normal network traffic to a zlib compressed stream, in the middle of the stream. My thoughts on this issue include a logical switch, which, when the call is turned on, will cause the network code to transmit all the data through a class that I can pass an IEnumerable<byte> , and then pull the unpacked stream, passing it to an existing parsing protocol code.

Things I looked at:

  • ZLib.NET - It seems a bit ... Ecclectic, and not quite what I want. However, it’s still a good idea to start building. ( John Skeet's comments here hardly inspire me.)
  • SharpZipLib - Does n't it seem to support zlib at all? Can anyone confirm or deny this?

I would really like everything to manage the solution, but let it have ... are there any other implementations of this library in .NET that may be better suited for what I want to do, or do I need to take ZLib.NET and build it like a start?

PS:

John asked in more detail, so here it is.

I am trying to implement MCCP 2 . This includes the signal sent in the network stream, and everything after this signal is a zlib compressed data stream. There are links to what they mean by this in the link above. In any case, to be clear, I am at the end of this (client, not server), and I already have a bunch of data read from the network stream, and the switch will be in the middle of this (probably at least), so any the solution should be able to add some additional data to it before it takes over NetworkStream (or I manually load the rest of the data).

+7
c # zlib
source share
5 answers

SharpZipLib supports ZLib. Check out this entry in the FAQ .

Also, did you check if the System.IO.Compression namespace supports what you need?

I would not use IEnumerable<byte> streams, although they are designed to connect to each other.

EDIT: Okay ... it looks like you need a stream that supports buffering, but with more control than BufferedStream . You will need to “rewind” the stream if you see a decompression switch, and then create a GZipStream on top of it. Your buffer should be at least as large as your largest Read () call so that you always have enough buffer to rewind.

+3
source share

Included in DotNetZip is ZlibStream , for compressing or decompressing zlib data streams. You did not ask, but there are also GZipStream and DeflateStream. Like the ZlibCodec class if this is your thing. (just inflates or deflates buffers, unlike threads).

DotNetZip is a fully managed library with a liberal license. You do not need to use any of the .zip features to access Zlib content. And zlib stuff is packaged as a separate (smaller) DLL for this purpose.

+3
source share

Does the accepted answer in this post accept: Zlib-compatible compression streams will help you at all?

+2
source share

I can recommend you Gerry Shaw zlib wrapper for .NET:

http://www.organicbit.com/zip/

0
source share

As far as I know, the ZLib library (gzip) does not support listing files in the header. Assuming this is important to you, but it seems like a big drawback. This was when I used the sharp zip library a while ago, so I want to remove it :)

0
source share

All Articles