I had this same problem when I started on my Vista laptop. Some things to look for.
-Anti Virus - Which AV are you using. Some will cause problems. 2 I know for a fact work are AVG free and MSE
-UAC- if your User Account Control prompt is enabled, it will pop up behind the game, but disappear when you change focus (i.e. desktop) or close the game. This is stopping the connection because it’s asking your permission for something 😛
-Firewall - I’ve never had to disable mine, but if the above two don’t fix your problem, try temporarily disabling your firewall, or setting an exception to the game.
I’m sure there could be other reasons, but this is from my experience and advice given to me, hope it helps.