BUG/TST: catch socket.error in py2/3.2 and ConnectionError in py3.3

closes #3982.