Speed up with threads

Rhymes raims at dot.com
Sat Aug 3 11:07:27 CEST 2002

I've written a simple portscanner (two version: the first without
threads and the second one with threads). I just want to speed up more
the scanning, what can i do?

----------- code snippets -----------------
# this is a reasonable limit. 

# it's the inherited run() method of the scanner class 
# (inherits threading.Thread)
def run(self):
            # connect to the given host:port
            self.sd.connect((self.host, self.port))
            print "%s:%d OPEN" % (self.host, self.port)
        except: pass

# the scan method of the main class
def scan(self, host, start, stop):
        self.port = start
        while self.port < stop:
            while threading.activeCount() < MAX_THREADS:
                Scanner(host, self.port).start()
                self.port = self.port + 1

Rhymes (rhymes at myself.com)
" ride or die "

More information about the Python-list mailing list