Updated rescue to catch other errors from the socket API