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.
source to share
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 ...
source to share