OpenSSL (0.9.6g) has support for compression, both using RLE and ZLIB.

The way ZLIB is used, calls to the compress() function are made on each block of data transmitted.

Compress() is a higher-level function that calls deflateInit(), deflate() and deflateEnd().

 

I am trying to understand why ZLIB is being used that way.  Here is what gives better results on a continuous reliable stream of data:

 

1)       You create a z_stream for sending, and another z_stream for receiving.

2)       You call deflateInit() and inflateInit() on them, respectively, when the communication is established.

3)       For each data block you send, you call deflate() on it.  For each data block you receive, you call inflate() on it.

4)       When the connection is terminated, you call deflateEnd() and inflateEnd() respectively.

 

There are many advantages to that.  For one, the initialization functions are not called as often.

But by far, the main advantage is that you can achieve good compression even for very small blocks of data.  The "dictionary" window stays open for the whole communication stream, making it possible to compress a message by reference to a number of previously sent messages.

 

Thank you for sharing your ideas on this,

 

Eric Le Saux

Electronic Arts

 

 

 

 

 

Reply via email to