Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 222553
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T19:08:17+00:00 2026-05-11T19:08:17+00:00

I need to implement a special ZLib implementation which should run under .Net and

  • 0

I need to implement a special ZLib implementation which should run under .Net and Mono.
The data /string messages are received via a socket and thus the checksum is missing.
This is about raw string data, not about files.

    unsigned char zlib_header[]={
// custom additional Zlib Id
       'Z',    // Our own ID
// The normal GZIP header
       0x1f,
       0x8b,   // GZIP ID
       0x08,   // Deflated
       0x00,   // Flags
       0, 0, 0, 0, // Timestamp,
       0x00,   // Extra flags
       0x00,   // OS identifier
// afterwards compressed data without a checksum
};

I have tried to decompress the data with GZipStream and DeflateStream, but I think that GZStream fails because of the missing checksum. I have also tried various offsets, but had no luck.
The checksum is not used because the data is received via a socket anyway – thus the ZLib checksum would be additional overhead.
Have I missed something or could you explain me how to add the checksum and call the right library then or should I look at a 3rd party library which supports Mono and .Net?
Edit: Performance is very critical as this done at least once a second. Would you recommend me at the end to use the C-Lib via Interop?
I always receive Invalid Data Exception at the moment and I assume that it is related to the wrong checksum.
This is the actual code which I tried to use without success:

const int HeaderSize = 1;
System.IO.MemoryStream ms = new System.IO.MemoryStream(compressedBuffer, HeaderSize, compressedBuffer.Length-HeaderSize);//remove the additional Z from the header
GZipStream zipStream = new GZipStream(ms, CompressionMode.Decompress,true);
byte[] deCompressedBytes = new byte[actualBufferLength* 10];
int resultSize=zipStream.Read(deCompressedBytes, 0, actualBufferLength);//get rid of the header      
UTF8Encoding enc = new UTF8Encoding();
string result = enc.GetString(deCompressedBytes, 0, resultSize);
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-11T19:08:17+00:00Added an answer on May 11, 2026 at 7:08 pm

    Are you sure it has to do with the checksum?

    The 32-bit checksum is not optional in the GZIP format. I don’t understand what you mean by “the data is received via socket thus the checksum is missing”. It doesn’t matter if you get the data via carrier pigeon; if it is a valid GZIP stream, it must have a 32 bit CRC. Who or what produced the source data?

    There is an optional part in the GZIP spec – the 16-bit checksum. (its inclusion is also not predicated on how the GZIP bytestream was created.) The System.IO.GZipStream class will gladly accept a GZIP stream that lacks this CRC16, as well as one that includes it.

    You have some other problems in the code. The actualBufferLength in your code – what is that? It is certainly not the length of the buffer to hold the decompressed data. That is 10x. But 10x seems pretty arbitrary. For very compressible data, you may exceed 10x. I suggest you use a streaming approach in decompression.

    As for whether you will be able to handle a 1-per-second decompression, yes, the System.IO.GZipStream will be fast enough for small enough chunks of data. There is likely no need to go to a native C/C++ library.

    ps: The DotNetZip library includes a GZipStream that is open source; you can use it out of the box or if you like, you can just grab the GZip stuff if that is all you need.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 124k
  • Answers 124k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer Are you running on OS 3.0? I saw the same… May 12, 2026 at 1:19 am
  • Editorial Team
    Editorial Team added an answer It looks like you need to register Apache::Session::Memcached with Apache::Session::Wrapper,… May 12, 2026 at 1:19 am
  • Editorial Team
    Editorial Team added an answer Use DATENAME or DATEPART: SELECT DATENAME(dw,GETDATE()) -- Friday SELECT DATEPART(dw,GETDATE())… May 12, 2026 at 1:19 am

Related Questions

I'm a little stumped on this one. Anyone have any ideas? I'll try to
I have a simple model called Party with a corresponding table called parties .
I am looking to implement something similar to facebook/gmail chat. I know they use
I'd like to create a data table given a List using the CopyToDataTable method

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.