private void ReadNextPacket(int len)
        {
            if (!Platform.IsMono())
            {
                inBuffer = inBufferRef.Target as byte[];
            }

            if (inBuffer == null || inBuffer.Length < len)
            {
                inBuffer = new byte[len];
            }
            MyCatStream.ReadFully(baseStream, inBuffer, 0, len);
        }
        private void PrepareNextPacket()
        {
            MyCatStream.ReadFully(baseStream, lengthBytes, 0, 7);
            int compressedLength = lengthBytes[0] + (lengthBytes[1] << 8) + (lengthBytes[2] << 16);
            // lengthBytes[3] is seq
            int unCompressedLength = lengthBytes[4] + (lengthBytes[5] << 8) +
                                     (lengthBytes[6] << 16);

            if (unCompressedLength == 0)
            {
                unCompressedLength = compressedLength;
                zInStream          = null;
            }
            else
            {
                ReadNextPacket(compressedLength);
                MemoryStream ms = new MemoryStream(inBuffer);
                zInStream          = new ZInputStream(ms);
                zInStream.maxInput = compressedLength;
            }

            inPos    = 0;
            maxInPos = unCompressedLength;
        }