Solved

Compressing data to be sent through Winsock

Posted on 2004-08-09
3
457 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

How to remove superseded packages in windows w60 or w61 installation media (.wim) or online system to prevent unnecessary space. w60 means Windows Vista or Windows Server 2008. w61 means Windows 7 or Windows Server 2008 R2. There are various …
The purpose of this article is to demonstrate how we can use conditional statements using Python.
The viewer will be introduced to the technique of using vectors in C++. The video will cover how to define a vector, store values in the vector and retrieve data from the values stored in the vector.
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.

948 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

Need Help in Real-Time?

Connect with top rated Experts

22 Experts available now in Live!

Get 1:1 Help Now