Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

compressing socket send data

Tags:

c++

c

I'm trying to send a lot of data(basically data records converted to a string) over a socket and its slowing down the performance of the rest of my program. Is it possible to compress the data using gzip etc. and uncompress it at the other end?

like image 268
aks Avatar asked Nov 19 '25 21:11

aks


2 Answers

Yes. The easiest way to implement this is to use the venerable zlib library.

The compress() and uncompress() utility functions may be what you're after.

like image 85
caf Avatar answered Nov 22 '25 12:11

caf


Yes, but compression and decompression have their costs as well.

You might want to consider using another process or thread to handle the data transfer; this is probably harder than merely compressing, but will scale better when your data load increases n-fold.

like image 29
msw Avatar answered Nov 22 '25 13:11

msw



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!