Turn off your firewall? If it works, then your firewall is blocking something and you can then do some investigation to figure out exactly what. Once you know that, you can add a rule that opens up whatever your firewall is blocking. According to
this page, it could also be that another program is attempting to access the same socket. Perhaps you are not closing the socket correctly before creating a new one, so you are stepping on your own toes. Or maybe another program is attempting to access the same remote server. Not quite sure, but those are some ideas for you to look into.