title: The magic number in gzip header is not correct
body: <p>Task: there are 2 clients. They must compress byte array, send it, receive byte array, decompress it and do something with result.<br>
  I use TCP for sending and receiving.<br>
  The error arises in the decompress method.</p>
  
  <p>Sending method:</p>
  
  <pre><code>private static void AsiooutOnAudioAvailable(object sender, AsioAudioAvailableEventArgs e)
  {
      audio = SamplesToBytes(monoSamples); 
      byte[] compressedBytes = CompressBytes(audio);
  
      if (_isConnected)
      {
          Task.Run(() =&gt; _receiver.BeginSend(compressedBytes, 0, compressedBytes.Length, SocketFlags.None, SendCallback, null));
      }
  }
  </code></pre>
  
  <p>Receiving:</p>
  
  <pre><code>private static void Receive()
  {
      _receiver.BeginReceive(incomingBytes, 0, incomingBytes.Length, SocketFlags.None, ReceiveCallback, null);
  }
  
  private static void ReceiveCallback(IAsyncResult ar)
  {
      int receivedBytesCount = _receiver.EndReceive(ar);
      byte[] _audio = new byte[receivedBytesCount];
      for (int i = 0; i &lt; receivedBytesCount; i++)
      {
          _audio[i] = incomingBytes[i];
      }
      var decompressBytes = DecompressBytes(_audio);
      _incomingBuffer.AddSamples(decompressBytes, 0, decompressBytes.Length);
      Receive();
  }
  </code></pre>
  
  <p>Compression and decompression</p>
  
  <pre><code>public static byte[] CompressBytes(byte[] bytes)
  {
      using (MemoryStream output = new MemoryStream())
      {
          using (GZipStream gzip = new GZipStream(output, CompressionMode.Compress))
          {
              gzip.Write(bytes, 0, bytes.Length);
          }
          return output.ToArray();
      }
  }
  
  static byte[] DecompressBytes(byte[] gzip)
  {
      using (GZipStream stream = new GZipStream(new MemoryStream(gzip), CompressionMode.Decompress))
      {
          int size = gzip.Length;
          byte[] buffer = new byte[size];
          using (MemoryStream memory = new MemoryStream())
          {
              int count = 0;
              do
              {
                  count = stream.Read(buffer, 0, size); //error place
                  if (count &gt; 0)
                  {
                      memory.Write(buffer, 0, count);
                  }
              }
              while (count &gt; 0);
              return memory.ToArray();
          }
      }
  }
  </code></pre>