Question

To save network traffic I'd like to compress my data. The only trick is that I the client is a c application and the server is php. I'm looking for an open source compression library that's available for both c and php.

I guess I could write an external c application to decompress my data, but I'm trying to avoid spawning extra processes on the server.

If you know of any, please post it!

Was it helpful?

Solution

Zlib provides C APIs, and is part of the PHP functional API as well.

OTHER TIPS

gzip is one of the most (if not the most) popular compression scheme. PHP has supported it since version 4. If you need even better compression, consider bzip2.

Php supports zlib compression and for the c compression you could use zlib, but you should think again if you want to compress network communication - the load will probably be too much for your servers.

You can probably instruct your web server to compress the data for you at the HTTP level, and then you won't have to worry about it on either end. For Apache, have a look at mod_deflate.

it depends on what data you are transferring. If it is text, use mod_gzip on apache (I am assuming you are using it). I have seen around 70% text compression with this. But if you are dealing with binary data, like images and videos, use media formats which are more compressible.

ZLIB

Here's the page on accessing zlib from PHP.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top