Solved

Compressing data to be sent through Winsock

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

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 143

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

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Enums (shorthand for ‘enumerations’) are not often used by programmers but they can be quite valuable when they are.  What are they? An Enum is just a type of variable like a string or an Integer, but in this case one that you create that contains…
When we want to run, execute or repeat a statement multiple times, a loop is necessary. This article covers the two types of loops in Python: the while loop and the for loop.
The viewer will learn how to pass data into a function in C++. This is one step further in using functions. Instead of only printing text onto the console, the function will be able to perform calculations with argumentents given by the user.
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.

856 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