fix deprecated `socket.error` exception