This week's giveaway is in the JDBC forum.
We're giving away four copies of Java Database Connections & Transactions (e-book only) and have Marco Behler on-line!
See this thread for details.
Win a copy of Java Database Connections & Transactions (e-book only) this week in the JDBC forum!

A Volang

Greenhorn
+ Follow
since Aug 21, 2018
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
0
Received in last 30 days
0
Total given
0
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by A Volang


Appreciate it. Thanks.

Another thing I was thinking about. I get an http request with header Connection: keep-alive. So I respond with the same header (keep-alive). So why does it create a new connection to request favicon instead of requesting favicon on the same connection?

It does not seem like it matters that I respond with Connection: keep-alive
I have written a few simple lines to find out what the browser is sending to the server when requesting a new page. This is from the server (there is no error checking, this is for testing purposes only) . It's written in c++, but you will understand it.


connections[i] = accept (server_socket, null, null);
cout << recv (connections[i], buffer, 600, 0) << "\n\n";
cout << buffer << "\n\n";

i++;



Then I copy this entire code and repeat it 5 times. Now that I have this ready, I start the server and open up my browser (Chrome). In the adressfield am writing localhost:27015, then I press enter. So now lets see what’s happening in the server console …

First, it prints out the number of bytes received (that’s what recv() returns if no errors have occurred). And after that, the entire http request will be printed out. So this is for the first socket. But then it prints zero(0) for the next socket, no message received. And another zero for a third socket, without any message received here either (zero means that the client has closed the socket).

After that, the program is blocked. So apparently Chrome created 3 connections when I wrote localhost:27015 in the browser. The first comes with a full message / http request, but what’s the purpose of the other 2? They both return zero(0). Why do they create 2 additional connections that they then close immediately? (Or have them been paused maybe?)

I also do not think it’s favicon that causes this. Because I get a separate request for favicon, as soon as I respond to the first http request. Note that this happens only with Chrome. IE only creates one connection initially.


Neo