[
  {
    "Id": "1233861",
    "ThreadId": "542193",
    "Html": "Hi,<br />\nI have been trying to implement Zlib Inflater with Z_SYNC_FLUSH.<br />\nThis is my Code:<br />\n<pre><code>        private ZlibCodec decompress = new ZlibCodec(CompressionMode.Decompress);\n\n    private byte[] DecompressSync(byte[] input)\n        {\n            byte[] outBytes = new byte[input.Length * 100];\n            decompress.InputBuffer = input;\n            decompress.NextIn = input.Length;\n\n            decompress.OutputBuffer = outBytes;\n            decompress.NextOut = outBytes.Length;\n            \n\n            int retval = 0;\n            do\n            {\n                retval = decompress.SyncInflate();\n                //retval = decompress.Inflate(FlushType.Sync);\n                switch (retval)\n                {\n                    case Ionic.Zlib.ZlibConstants.Z_OK:\n                    // completed decompression, lets copy data and get out\n                        break;\n                        break;\n                    default:\n                        Debug.WriteLine(&quot;Error= &quot; + retval);\n                        break;\n                }\n            } while (decompress.AvailableBytesIn &gt; 0);\n            return outBytes.Take(decompress.AvailableBytesOut).ToArray();\n        }</code></pre>\n\nI get IndexOutOfRangeException at decompress.SyncInflate(); or decompress.Inflate(FlushType.Sync); <a href=\"http://svn.apache.org/repos/asf/mina/mina/branches/1.0/filter-compression/src/main/java/org/apache/mina/filter/support/Zlib.java\" rel=\"nofollow\">This is an example of its implementation in java</a>.<br />\n<br />\nI have to use Zlib SYNC_FLUSH only and cannot use any other approach (required by the RFB protocol) Can someone please provide me some example of this in C#?<br />\n",
    "PostedDate": "2014-04-14T04:39:36.817-07:00",
    "UserRole": null,
    "MarkedAsAnswerDate": null
  }
]