Solved

Compressing data to be sent through Winsock

Posted on 2004-08-09
3
465 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

PeopleSoft Has Never Been Easier

PeopleSoft Adoption Made Smooth & Simple!

On-The-Job Training Is made Intuitive & Easy With WalkMe's On-Screen Guidance Tool.  Claim Your Free WalkMe Account Now

Question has a verified solution.

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

Go is an acronym of golang, is a programming language developed Google in 2007. Go is a new language that is mostly in the C family, with significant input from Pascal/Modula/Oberon family. Hence Go arisen as low-level language with fast compilation…
This article is meant to give a basic understanding of how to use R Sweave as a way to merge LaTeX and R code seamlessly into one presentable document.
The goal of the video will be to teach the user the concept of local variables and scope. An example of a locally defined variable will be given as well as an explanation of what scope is in C++. The local variable and concept of scope will be relat…
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.

696 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