Hi Sri,
I've tested your code and it's working!
The most common reason for a "connection refused" error is, if a host is reachable but it doesn't offer the service (HTTP in your case) you want to use. But in this case I don't think this is the reason unless someone has shutdown Microsoft's web servers
If a firewall would block the HTTP connections you'd usually get another error or just a timeout and it wouldn't be possible to surf on the internet from the host you're
testing this program.
The only reason I can imagine is, that you are behind a proxy server! Do you try this at home or at work? Perhaps you can check if you have configured a proxy in the settings for your browser?
Marco