def _create_socket(self): # pragma: no cover socket = ReliableSocket() socket.settimeout(_SCIOND_TOUT) try: socket.connect(self._api_addr) except OSError as e: socket.close() raise SCIONDConnectionError(str(e)) return socket
def _try_sciond_api(self): sock = ReliableSocket() msg = b'\x00' + self.dst.isd_as.pack() start = time.time() try: sock.connect(self.sd.api_addr) except OSError as e: logging.critical("Error connecting to sciond: %s", e) kill_self() while time.time() - start < API_TOUT: logging.debug("Sending path request to local API at %s", self.sd.api_addr) sock.send(msg) data = Raw(sock.recv()[0], "Path response") if data: sock.close() return data logging.debug("Empty response from local api.") logging.critical("Unable to get path from local api.") sock.close() kill_self()