Re: threads/sockets quick question.

2005-09-19 Thread [EMAIL PROTECTED]
The problem may be something to do with using "threading" as identifier name. It is name of a module and definitely what you want it done anyway. You are better off having another variable as counter (with a different name). Raghu. -- http://mail.python.org/mailman/listinfo/python-list

Re: threads/sockets quick question.

2005-09-19 Thread Ed Hotchkiss
Let's say that I avoid the complexities of using classes, and that I avoid using anything to count the threads...   import socketimport threading def scan(ip, port):    try:    s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)    s.connect((ip, port))    s.close()    print '%s |

Re: threads/sockets quick question.

2005-09-19 Thread dowskimania
ed wrote: > this script should create individual threads to scan a range of IP > addresses, but it doesnt, it simple ... does nothing. it doesnt hang > over anything, the thread is not being executed, any ideas anyone? [SNIP] > while threading < MAX_THREADS: > scanThre

Re: threads/sockets quick question.

2005-09-19 Thread Simon Percivall
Why do you check if the module threading is less than 50? (this is why nothing happens, it's always false). >From where do you get port_counter in method run() of scanThread? (this would make every call to run() raise an exception. -- http://mail.python.org/mailman/listinfo/python-list

Re: threads/sockets quick question.

2005-09-19 Thread n00m
import socket import thread def scan(ip, port): try: s = socket.socket(socket.AF_INET, socket.SOCK_STREAM) s.connect((ip, port)) s.close() print '%s | %d OPEN \nscanned: %d' % (ip, port, port) except: pass ip = 'localhost' for port in range(50, 5000

Re: threads/sockets quick question.

2005-09-19 Thread Bryan Olson
Fredrik Lundh wrote: > Bryan Olson wrote: > >>Next, you never create any instances of scanThread. > > > one would think that the "scanThread()" part of > > scanThread().start() > > would do exactly that. And one would be correct. I hereby retract that assertion of my post. -- --B

Re: threads/sockets quick question.

2005-09-19 Thread antred
maybe try this while threading.activeCount() < MAX_THREADS: # instead of while threading < MAX_THREADS: -- http://mail.python.org/mailman/listinfo/python-list

Re: threads/sockets quick question.

2005-09-19 Thread antred
Ah shoot, never mind, I'm an idiot. =0 -- http://mail.python.org/mailman/listinfo/python-list

Re: threads/sockets quick question.

2005-09-19 Thread antred
This may be a really stupid question, but are you actually CALLING your scan() function anywhere? -- http://mail.python.org/mailman/listinfo/python-list

Re: threads/sockets quick question.

2005-09-19 Thread Piet van Oostrum
> "ed" <[EMAIL PROTECTED]> (E) wrote: > import socket > import threading > import traceback > def scan(ip, thebegin, theend): > global ip > global thebegin > global theend Making parameters global is a bad idea (I think). Moreover, thebegin and theend aren't used in s

Re: threads/sockets quick question.

2005-09-19 Thread Piet van Oostrum
> Bryan Olson <[EMAIL PROTECTED]> (BO) wrote: >BO> ed wrote: >>> this script should create individual threads to scan a range of IP >>> addresses, but it doesnt, it simple ... does nothing. it doesnt hang >>> over anything, the thread is not being executed, any ideas anyone? >BO> It's because

Re: threads/sockets quick question.

2005-09-19 Thread Fredrik Lundh
Bryan Olson wrote: > Next, you never create any instances of scanThread. one would think that the "scanThread()" part of scanThread().start() would do exactly that. -- http://mail.python.org/mailman/listinfo/python-list

Re: threads/sockets quick question.

2005-09-19 Thread ed
import socket import threading import traceback class scanThread(threading.Thread): def run(self): try: ss = socket.socket(socket.AF_INET, socket.SOCK_STREAM) ss.connect((ip, port_counter)) print "%s | %d OPEN" % (ip, port_counter) ss.cl

Re: threads/sockets quick question.

2005-09-19 Thread Ed Hotchkiss
  Well, I fixed those problems, now what I have is this: but i am getting errors with the global variables or something ... am i supposed to use this class and def together differently? I just don't seem to understand ... -edward import socketimport threadingimport traceback class scanThread(thr

Re: threads/sockets quick question.

2005-09-19 Thread Bryan Olson
ed wrote: > this script should create individual threads to scan a range of IP > addresses, but it doesnt, it simple ... does nothing. it doesnt hang > over anything, the thread is not being executed, any ideas anyone? It's because of the bugs. Nothing happens because threading < MAX_THREADS

threads/sockets quick question.

2005-09-18 Thread ed
this script should create individual threads to scan a range of IP addresses, but it doesnt, it simple ... does nothing. it doesnt hang over anything, the thread is not being executed, any ideas anyone? -- import socket import threading import traceback MAX_THREADS = 50 class scanThrea