0

I want to write an application that connects to a server to download an image so that after receiving the header response with the pic size, I can spawn one or more threads to download the image and measure download speed...

I’m just doing this for fun and would like to know how to approach the problem.

More specifically:

  1. How do I get the header back so that I can parse it and find the image size?

  2. Once that’s achieved how do I download the image using more than one thread?

Thanks!

matt-eo
  • 3
  • 4
  • As the duplicate states, the server must support this – Hovercraft Full Of Eels Dec 13 '20 at 15:12
  • The duplicate only answers question #2. However, @Matt_eo88 - don't put two separate and mostly unrelated quetions in a single SO question. File another question for your first issue if you want. – rzwitserloot Dec 13 '20 at 15:13
  • 1
    I also find the linked question confusing, in that it fails to state the obvious: For the vast majority of client/server relationships out there, multithreading the request only slows things down. The bottleneck is going to be the network pipe or the disk of the server, or the disk of the client, and introducing threads will only slow things down; sometimes significantly so by introducing more overhead and forcing disjointed reads or writes (bouncing the write or read head on a harddisk around more than needed). – rzwitserloot Dec 13 '20 at 15:15
  • 1
    @Matt_eo88 It sounds like what you actually want has nothing to do with the linked question: You want to download the same image multiple times to measure download speed, but if you do so in multiple threads, obviously, that is not how you measure download speed. If the bottleneck is e.g. the connection between your house and the routerbox down the street, then downloading 4 at once means each individual download is only 25% as fast as it should be. And that so happens to be the most common bottleneck, thus, why it is a very very bad idea to use threads here in the first place. – rzwitserloot Dec 13 '20 at 15:16

0 Answers0