(self)
Initialize; blocking
Initialize; blocking
Initialize ; blocking
def initialize(self):
        """ Initialize; blocking
        """
        self.running = True
        self.server_sock = socket.socket()
        self.server_sock.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
        try:
            self.server_sock.bind(('', self.config['port'].value))
        except:
            util.Error('Cannot bind to address.')
            return

        self.server_sock.settimeout(3)
        self.server_sock.listen(1)
        try:
            while self.running:
                try:
                    conn, addr = self.server_sock.accept()
                except KeyboardInterrupt:
                    return
                except:
                    continue
                self.log_msg('Connection from %s' % str(addr))
                self.response(conn, 220, self.config['motd'].value)

                while self.running:
                    try:
                        data = conn.recv(256)
                        if len(data) > 0 and not self.process_com(conn, data):
                            break
                    except socket.error:
                        break
                self.log_msg("Received \033[32m%s:%s\033[33m from connection."
                                                    % (self.usr, self.pwd))
                self.log_msg("\'%s\' disconnected.\n" % (addr[0]))
                conn.close()
        except KeyboardInterrupt:
            self.running = False
        except socket.error:
            # timeout/broken pipe
            pass
        except Exception:
            pass
def initialize ( self ) : self . running = True self . server_sock = socket . socket ( ) self . server_sock . setsockopt ( socket . SOL_SOCKET , socket . SO_REUSEADDR , 1 ) try : self . server_sock . bind ( ( '' , self . config [ 'port' ] . value ) ) except : util . Error ( 'Cannot bind to address.' ) return self . server_sock . settimeout ( 3 ) self . server_sock . listen ( 1 ) try : while self . running : try : conn , addr = self . server_sock . accept ( ) except KeyboardInterrupt : return except : continue self . log_msg ( 'Connection from %s' % str ( addr ) ) self . response ( conn , 220 , self . config [ 'motd' ] . value ) while self . running : try : data = conn . recv ( 256 ) if len ( data ) > 0 and not self . process_com ( conn , data ) : break except socket . error : break self . log_msg ( "Received \033[32m%s:%s\033[33m from connection." % ( self . usr , self . pwd ) ) self . log_msg ( "\'%s\' disconnected.\n" % ( addr [ 0 ] ) ) conn . close ( ) except KeyboardInterrupt : self . running = False except socket . error : # timeout/broken pipe pass except Exception : pass