Solved

Compressing data to be sent through Winsock

Posted on 2004-08-09
3
459 Views
Last Modified: 2013-11-13
Hello,

I have a client/server application where the server sends a file to the client application as a byte stream using the Winsock control. I would like to compress the stream (using zlib or something similar) in the server, then decompress it in the client.

I've found an example using zlib that compress the whole file at once, but since some files are very large, I want to compress each data chunk that is sent on the fly. Is there a way to accomplish that?

Thanks in advance,

Ricardo.
0
Comment
Question by:ricardog2
  • 2
3 Comments
 
LVL 142

Expert Comment

by:Guy Hengel [angelIII / a3]
ID: 11761175
Compression performance gets potentially better the larger the file is, because of the possible data pattern that can be compressed that way. If you want to compress small chunks, the results may even become negative, as compression also starts with some overhead.
If you have a really large file (say > 50MB), then you might start splitting the file into chunks of 10MB, zip them and send send the zipped chunks...
To split the files, you have to binary read the files and binary write the chunks... Don't forget to send to the client how many and how big the chunks are, best would also be to send some hash code of the chunks and the total to check the several results...

CHeers
0
 
LVL 1

Author Comment

by:ricardog2
ID: 11802097
I can calculate the number of compressed chunks that will be sent before the transfer begins, but how would I know their size? Unless I split the whole file at once (which I don't want to do because that would require too much disk space), I can only notify the client of the next chunk size during the transfer, but then I would have a problem to separate the file data from the chunk size data.

Any ideas?
0
 
LVL 142

Accepted Solution

by:
Guy Hengel [angelIII / a3] earned 250 total points
ID: 11803944
Yes, have 2 connections open to the client, 1 for the data transfer, and 1 for the information/command transfer.
That's how I have managed to do such kind of things...
Cheers
0

Featured Post

Optimizing Cloud Backup for Low Bandwidth

With cloud storage prices going down a growing number of SMBs start to use it for backup storage. Unfortunately, business data volume rarely fits the average Internet speed. This article provides an overview of main Internet speed challenges and reveals backup best practices.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
split53 challenge 7 96
VBA: Select SQL query based on a config Sheet v2 11 44
I need help embedding an image as HTML in my vb.net application 3 68
Problem to App 4 82
Having just graduated from college and entered the workforce, I don’t find myself always using the tools and programs I grew accustomed to over the past four years. However, there is one program I continually find myself reverting back to…R.   So …
If you haven’t already, I encourage you to read the first article (http://www.experts-exchange.com/articles/18680/An-Introduction-to-R-Programming-and-R-Studio.html) in my series to gain a basic foundation of R and R Studio.  You will also find the …
The viewer will learn how to implement Singleton Design Pattern in Java.
The viewer will be introduced to the member functions push_back and pop_back of the vector class. The video will teach the difference between the two as well as how to use each one along with its functionality.

772 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question