Stream compression for network traffic

I am writing an xmpp library and I am trying to write a stream to support zlib compressed data. I have two different versions based on zlib.net and the other one based on SharpZipLib. The zlib.net version does not recognize compression, and the SharpZipLib version goes into an infinite loop. You can find the relevant code at http://github.com/coder2000/ubiety/tree/master/ at xmpp.compression.zlib and xmpp.compression.sharpziplib. Any help to fix this issue would be appreciated.

0


source to share


3 answers


This is not a direct solution to your problem, but have you tried System.IO.Compression.GZipStream or DeflateStream?



+1


source


Not. I try to be as cross platform as possible. I don't know if Mono implements these classes, and I didn't know that Microsoft wrote classes to compress zlib.



+1


source


I have not looked in depth, but it is curious that your wrapper SharpZipLib ignores offset

and count

in BeginRead:

public override IAsyncResult BeginRead (byte[] buffer, int offset, int count, AsyncCallback cback, object state)
{
  _outBuff = buffer;
  if ( _in.IsNeedingInput )
    return _innerStream.BeginRead(_inBuff, 0, _inBuff.Length, cback, state);

  ZlibStreamAsyncResult ar = new ZlibStreamAsyncResult(state);
  cback(ar);
  return ar;
}

      

Call me crazy, but probably use GZipOutputStream

etc. directly (or a copy of System.Compression) ... retains a lot of implementation details ...

0


source







All Articles