Accepting a socket in Windows 7 takes more than a second

Here is what I did:

  • I wrote a minimal web server (using Qt, but I don't think it matters here).
  • I am running it on legit 32-bit Windows 7.

Problem:

  • If I make a request with Firefox, IE, Chrome or Safari, it will take about a second before my server sees that there is a new connection that will be accepted.

Evidence:

  • Using other clients (wget, your own test client that only opens the socket) than Firefox, IE, Chrome, Safari, seeing a new connection, is milliseconds.
  • I installed Apache and tried the above clients. The query takes ~ 50 ms as expected.
  • The problem does not reproduce when running Windows XP (or compiling and running the same code on Linux)
  • The problem seems to be present only when connecting to localhost. A friend connected over the Internet and serving the connection was a matter of milliseconds.
  • Starting the server in different ports does not affect the delay of 1 second.

Here is what I tried with no luck:

  • Windows Defender Service Stopped
  • Windows Firewall Service Stopped

Any ideas? Is this some kind of smart "security feature" in Windows 7? Why is Apache not affected? Why are only browsers affected?

+5
source share
3 answers

If you say "localhost" instead of "127.0.0.1", you force the search for the name before the actual connection attempt, adding a delay.

, , Firefox 3.5+, DNS , , , , wget.

+3

- Windows 7 1 , , , hosts.

localhost1 hosts .

+4

, . Firefox Options | | | ; " " . Internet Properties, IE, Windows . , -. .

+3
source

All Articles