I need to transmit integral data types over the network, but I donโt want to transfer all 32 (or 64) bits all the time - the data fits in one byte 99% of the time - so it seems like I need to compress it somehow: for example, the first bit of the byte is 0, if the other 7 bits mean only a certain value (0-127), otherwise (if the first byte is 1), he needs to shift these 7 bytes to the left and read the second byte to do the same process.
Is there a general way to do this? I do not want to reinvent the wheel ...
Thank.
source
share