Exemple #1
0
    def start(self):
        try:
            server = socket.socket()
            server.setblocking(0)
            server.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
            server.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1)

            server.bind((self._host, self._port))
            server.listen(5)
            self._sock_host, self._sock_port = s.getsockname()
            self._peer_state = 'LISTENING'
            self._servers.append(server)
            self._clients.append(server)
            Handler.start(self)
            threading.Thread.start(self)
        except Exception as ex:
            logging.exception(ex)
            return None
Exemple #2
0
 def start(self):
     Handler.start(self)
     threading.Thread.start(self)