def _create_socket(self, addr): sock = ScionClientSocket(L4Proto.SSP, bytes(self.sd.api_addr, 'ascii')) sock.settimeout(API_TOUT) sock.bind(0, self.addr) sock.connect(self.dst, self.dport) sock.settimeout(self._timeout) return sock
def _connect_to_target_proxy(self): """ Establishes a connection to the target SCION proxy. :returns: The socket that is connected to the target proxy. :rtype: socket """ if self.scion_mode: logging.info("Opening a SCION-socket") sockdir = "/run/shm/sciond/%s.sock" % self.isd_as soc = ScionClientSocket(L4Proto.SSP, bytes(sockdir, 'ascii')) soc.connect(self.scion_target_proxy, self.scion_target_port) if self.socket_kbase: self._handle_socket_options(soc) self.socket_kbase.add_socket(soc, self.conn_id, self.method, self.path) else: soc = self._unix_client_socket() return soc
def _create_socket(self, addr): sock = ScionClientSocket(L4Proto.SSP, bytes(self.api_addr, 'ascii')) sock.settimeout(API_TOUT) sock.bind(0, self.addr) if sock.connect(self.dst, self.dport) < 0: sock.close() return None sock.settimeout(self._timeout) payload_size = sock.max_payload_size() logging.debug("Max payload size = %d", payload_size) global DATA_LEN DATA_LEN = payload_size * 2 return sock
def _create_socket(self, addr): sock = ScionClientSocket(L4Proto.UDP, bytes(self.sd.api_addr, 'ascii')) if sock.bind(0, self.addr) < 0: return None sock.settimeout(self._timeout) return sock