For some hosts,
ping www.example.com it resolves their IP but why does it fails with request time out? I have also tried to increase the ping response time but still the same result.
A ping is an ICMP packet. For comparison, web traffic or HTTP, is generally a TCP packet on port 80. A given server may be providing responses for the purpose of web traffic, but block ICMP (or be behind a firewall that blocks ICMP) and therefore you can:
- Resolve the URL to its IP address
- Connect and view the web content
But you cannot ping the IP address. The response "request timed out" is because your client sends the initial packet, waits for a reply (which will never come), and gives up at a preset timeout.
Well, ping fails to www.microsoft.com too, for example. It is because those server computers use a restrictive firewall blocking the ICMP packets from unknown hosts.
Also ping does not "CONNECT" to a host, it just dispatches a single packet to them. TCP does connection handshakes and tries very hard to keep the connection. Ping just dispatches a ICMP packet which is not guaranteed to reach its destination. Just like UDP does, for data.
If it does not each its destination or the destination throws the packet away (firewall?), you don't get an answer.
This is completely independent from http traffic which uses TCP.