Compress array of data sent through sockets
We have a Server that sends some data to a client(both written using c++/MFC) using sockets The data is getting a little too big and I'm looking for solutions to compress it. Basically I need to compress some char Arrays
I am not very familiar with MFC. I looked at zlib but I had a hard time getting anything compiling with my VS project. I am also able to use CLI (I tried using GZipStream and got it to work on C# but when I tried it on c++ I can't manage to get the CLI 开发者_运维百科arrays to play nicely with the c++ char arrays)
Is zlib a mandatory requirement of your project ? Otherwise, some other programs have simpler header file, which are easier to work with. For example, this one (tested with GCC and MS's VS) :
int LZ4_compress (char* source, char* dest, int isize);
int LZ4_uncompress (char* source, char* dest, int osize);
Source code : http://code.google.com/p/lz4/
Take a look at http://zlib.net/
Also, there's a guy who did a wrapper around it (for convenience), might be worth checking it out: http://www.firstobject.com/easy-zlib-c++-xml-compression.htm
You can use any 3rd party compression library.
Also this question deals with a similar problem : c++ compress byte array
What error are you getting in trying to compile zlib.
精彩评论