zlib inflate error : Z_DATA_ERROR randomly
<p>I have an application that compresses and sends data via socket and data received is written in remote machine. During recovery, this data is decompressed and retrieved. Compression/Decompression is done using "zlib".But during decompression I face the following problem randomly:</p>

<p><strong>zlib inflate() fails with error "Z_DATA_ERROR" for binary files like .xls,.qbw etc.</strong></p>

<p>The application compresses data in blocks say "1024" bytes in a loop with data read from the file and decompresses in the same way.From the forum posts, I found that one reason for Z_DATA_ERROR is due to data corruption.  As of now, to avoid this problem, we have introduced CRC check of data compressed during send and what is received.
  Any possible reasons on why this happens is really appreciated! (as this occurs randomly and for the same file, it works the other time around).Is it bcoz of incorrect handling of zlib inflate() and deflate() ?
<strong>Note: If needed,will post the exact code snippet for further analysis!</strong></p>

<p>Thanks...Udhai</p>
