Reputation: 281
I am writing an xmpp library and I am trying to write a stream to support the zlib compressed data. I have two different versions one based on zlib.net and the other using SharpZipLib. The zlib.net version doesn't recognize the compression and the SharpZipLib version enters an infinite loop. You can find the appropriate code at http://github.com/coder2000/ubiety/tree/master/ in xmpp.compression.zlib and xmpp.compression.sharpziplib. Any help to solve this problem would be appreciated.
Upvotes: 0
Views: 1694
Reputation: 1063864
I haven't looked in depth, but it is curious that your SharpZipLib wrapper 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 the System.Compression counterparts)... saves a lot of implementation details...
Upvotes: 0
Reputation: 281
No. I am trying to be as cross platform as possible. I don't know if Mono implements those classes and I didn't know Microsoft wrote classes for zlib compression.
Upvotes: 1
Reputation:
This isn't a direct solution to your problem but have you tried System.IO.Compression.GZipStream or DeflateStream?
Upvotes: 1