5

I have a File Transfer Application that sends files and folders. (Server - client)
I am trying to send data over TCP (sockets), I've made some rules for the way of transferring the data, so if it's sending a large folder that has many files, it should compress them into a single zip file first then when that zip file sent, the receiver has to decompress it. so I have decided to use SharpZibLib and I have got a question about it.

  • Which type of compressing should i choose for my application?
    I read about the differences between ZIP and GZIP, and found that GZIP has better compression to reduce the size, and as I don't need to extract a special file from the GZIP file later, there's no need to use ZIP instead of GZIP!
    but in that library there are many types that I still don't know, so should I use GZIP or another type would be better for my application?

    enter image description here

    P.S: Priority for the time first, the point of using SharpZipLib is to put the (too many files) in a single file so it will be sent much faster than sending the (too many files) one by one.
    more details here.

  • Community
    • 1
    • 1
    Murhaf Sousli
    • 12,622
    • 20
    • 119
    • 185
    • Posts here should contain a single question, so a correct answer can be chosen. If you post multiple questions in the same post, it's conceivable that one person will answer one question, and a different person answers the second. In that case, how do you decide which one is correct? Sticking to one question per post solves that problem, and makes searching and finding answers easier. (The [FAQ](http://stackoverflow.com/faq) mentions this, BTW.) Thanks. :) – Ken White Apr 21 '12 at 23:10
    • @KenWhite I'm actually looking for advices, and i will choose the better answer that convince me, other answers can be rated. – Murhaf Sousli Apr 21 '12 at 23:18
    • Better answer to which question? You have two, so two totally separate answers are possible. As I said, read the FAQ. One post, one answer is the way this site is designed to work. :) – Ken White Apr 21 '12 at 23:19
    • @KenWhite i've edit the question, any ideas about the answer? – Murhaf Sousli Apr 21 '12 at 23:32
    • No, sorry. I've never used `SharpZipLib`, I'm afraid. +1 for the now extremely well-written question, though. :) My suggestion would be to write a quick test app that uses the various compression algos to compress the same data and compare speeds with your specific data, though, and then you can choose the exact best one for what you're doing. – Ken White Apr 21 '12 at 23:35
    • Why use SharpZipLib at all? The GZip compression in `System.IO.Compression` is good. And fast. It was much improved with .NET 4.0. – Jim Mischel Apr 21 '12 at 23:55
    • Zip and GZip are different formats, but both use the deflate algorithm internally. Deflate is a combination of LZ77 encoding, and Huffman encoding. LZW is based on LZ78 encoding, which is different. BZip2 is again a different algorithm (based on Burrows-Wheeler transform). Tar simply combines many files into one, and offers no compression at all. You'll probably want to do field testing to determine which is best for you in terms of average compression ratio, compression speed, and decompression speed (deflate offers very fast decompression). – Cameron Apr 21 '12 at 23:57
    • @Cameron so if the size of the compressed file doesn't matter, then TAR is the fastest to decompress and the meant one for the application? – Murhaf Sousli Apr 22 '12 at 00:14
    • That's not what Cameron said at all. He (and I) suggested that you should do testing with the various options to see what works best with your specific data as far as speed goes. You should actually read the entire response. :) – Ken White Apr 22 '12 at 03:52

    1 Answers1

    1

    For speed, you should use gzip / zip. I presume that the library allows you to select the compression level. You should experiment with low levels, e.g. 1 to 4, to see what speed and degree of compression works best with your application.

    gzip / zip will outperform LZW in speed at the same compression effectiveness. I find that compression level 3 is faster than LZW and compresses much better.

    bzip2 will compress better than gzip / zip, but will take much longer.

    The other choices are not compressors.

    Mark Adler
    • 101,978
    • 13
    • 118
    • 158