I'm trying to open about 25connections to a host at the same time.
My OS is windows 10.
For testing, I bring up a simple website on my local IIS
and I response a simple data to the user with a delay of 2 seconds using Thread.Sleep(2000)
.
Now using this code on the client:
const int len = 25;
for (int i = 0; i < len; i++)
{
new Thread(new ParameterizedThreadStart((idx) =>
{
// start downloading data.
var res = new WebClient().DownloadString("http://192.168.1.101:8090/");
// log index and time when done.
Console.WriteLine($"{Convert.ToInt32(idx).ToString("00")} done at:{ DateTime.Now.ToString("HH:mm:ss:ffff") }");
})).Start(i);
}
I got the following result:
Thread 01 done at 40:8476 ms
Thread 00 done at 40:8476 ms
Thread 03 done at 40:8496 ms
Thread 04 done at 40:8496 ms
Thread 02 done at 40:8506 ms
Thread 05 done at 40:8506 ms
Thread 07 done at 40:8516 ms
Thread 06 done at 40:8516 ms
Thread 08 done at 40:8536 ms
Thread 09 done at 40:8545 ms
Thread 11 done at 42:8510 ms
Thread 10 done at 42:8510 ms
Thread 12 done at 42:8560 ms
Thread 14 done at 42:8560 ms
Thread 15 done at 42:8570 ms
Thread 13 done at 42:8580 ms
Thread 16 done at 42:8590 ms
Thread 17 done at 42:8590 ms
Thread 18 done at 42:8610 ms
Thread 19 done at 42:8610 ms
Thread 21 done at 44:8565 ms
Thread 20 done at 44:8565 ms
Thread 23 done at 44:8634 ms
Thread 24 done at 44:8654 ms
Thread 22 done at 44:8654 ms
The above result tells us that:
1- Thread 0 to 9
got the data at the same time.(second 40)
2- Thread 10 to 19
got the data at the same time 2 seconds later after previous step.(second 42)
3- Thread 20 to 24
got the data at the same time. 2 seconds later after previous step.(second 44)
Now my question is WHO limited me and why it only opens 10 HTTP
connections at the same time and how can I set it to unlimited.
If there is any other platform or programming language it will be welcomed.