(self)
Overide Daemon.run() and provide sockets
Overide Daemon.run() and provide sockets
Overide Daemon . run () and provide sockets
def run(self):
        """Overide Daemon.run() and provide sockets"""

        while True:
            try:
                conn, client = self.sock.accept()
            except OSError:
                break

            logging.info('Connected to '+client[0]+':'+str(client[1]))
            conn.settimeout(60)

            try:
                parts = receive(conn).split(b'\xB2\xEA\xC0')
                cmd = parts.pop(0)
                if cmd in self.lookup:
                    self.lookup[cmd](conn, parts)
                else:
                    logging.error('Received a wrong command')
                    sendmsg(conn, b'FAIL: Command isn\'t available')
            except OSError as err:
                logging.error(err.__str__())
            finally:
                conn.shutdown(socket.SHUT_RDWR)
                conn.close()
def run ( self ) : while True : try : conn , client = self . sock . accept ( ) except OSError : break logging . info ( 'Connected to ' + client [ 0 ] + ':' + str ( client [ 1 ] ) ) conn . settimeout ( 60 ) try : parts = receive ( conn ) . split ( b'\xB2\xEA\xC0' ) cmd = parts . pop ( 0 ) if cmd in self . lookup : self . lookup [ cmd ] ( conn , parts ) else : logging . error ( 'Received a wrong command' ) sendmsg ( conn , b'FAIL: Command isn\'t available' ) except OSError as err : logging . error ( err . __str__ ( ) ) finally : conn . shutdown ( socket . SHUT_RDWR ) conn . close ( )