Beispiel #1
0
 def _setup_sockets(self, init):
     """
     Setup incoming socket and register with dispatcher
     """
     self._tcp_sock = None
     self._tcp_new_conns = queue.Queue(MAX_QUEUE)  # New TCP connections.
     if self._port is None:
         # No scion socket desired.
         return
     svc = SERVICE_TO_SVC_A.get(self.SERVICE_TYPE)
     # Setup TCP "accept" socket.
     self._setup_tcp_accept_socket(svc)
     # Setup UDP socket
     if self.bind:
         # TODO(jonghoonkwon): Fix me to setup socket for a proper bind address,
         # if the element has more than one bind addresses
         host_addr, b_port = self.bind[0]
         b_addr = SCIONAddr.from_values(self.topology.isd_as, host_addr)
         self._udp_sock = ReliableSocket(
             reg=(self.addr, self._port, init, svc), bind_ip=(b_addr, b_port))
     else:
         self._udp_sock = ReliableSocket(
             reg=(self.addr, self._port, init, svc))
     if not self._udp_sock.registered:
         self._udp_sock = None
         return
     self._port = self._udp_sock.port
     self._socks.add(self._udp_sock, self.handle_recv)
Beispiel #2
0
 def _setup_sockets(self, init):
     """
     Setup incoming socket and register with dispatcher
     """
     self._tcp_sock = None
     self._tcp_new_conns = queue.Queue(MAX_QUEUE)  # New TCP connections.
     if self._port is None:
         # No scion socket desired.
         return
     svc = SERVICE_TO_SVC_A.get(self.SERVICE_TYPE)
     # Setup TCP "accept" socket.
     self._setup_tcp_accept_socket(svc)
     # Setup UDP socket
     self._udp_sock = ReliableSocket(reg=(self.addr, self._port, init, svc))
     if not self._udp_sock.registered:
         self._udp_sock = None
         return
     self._port = self._udp_sock.port
     self._socks.add(self._udp_sock, self.handle_recv)