Example #1
0
    def _init_socket(self):
        # creating socket that accepts IPv4 address and works with TCP protocol
        self._main_sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
        Socket.set_socket_keep_alive(self._main_sock, keep_alive_time=5, keep_alive_interval=10, max_probes=10)
        self._main_sock.settimeout(1000)
        self._main_sock.bind((ip.get_local_ip_address(is_local_host=False), self.PORT))

        print(f'Server created on address: {ip.get_local_ip_address(is_local_host=False)}:{self.PORT}')
Example #2
0
 def _set_tcp_main_socket(self):
     # creating socket that accepts IPv4 address and works with TCP protocol
     self._tcp_main_sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
     self._tcp_main_sock.bind(
         (ip.get_local_ip_address(is_local_host=IS_LOCAL_HOST),
          self.TCP_PORT))
     self._tcp_main_sock.setblocking(False)
     self._inputs.append(self._tcp_main_sock)
     self._tcp_main_sock.listen(self.MAX_ACTIVE_CLIENTS)
Example #3
0
 def _set_udp_socket(self):
     self._udp_sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
     self._udp_sock.bind(
         (ip.get_local_ip_address(is_local_host=IS_LOCAL_HOST),
          self.UDP_PORT))