[Tutor] 3 questions for my port scanner project

Martin Walsh mwalsh at groktech.org
Sat Feb 26 16:28:03 CET 2005


Mark Kels wrote:

>Hi list.
>
>
>  
>
Hi Mark,

>2. I got a while loop which does the port scan itself. How can I end
>it while its working ?
>  
>
previous message with code: *http://tinyurl.com/3lobo*
**I'm not totally sure of this, but you might try adding another 
conditional to your while loop that can be toggled by a Scan and Stop 
button in your Tkinter app.

global ok_to_scan
ok_to_scan = 1 # or True
while (start_port <= end_port) and ok_to_scan:
    # ... do scan ...
    root.update()

then bind a function to a Stop button which toggles 'ok_to_scan' to 0 
(or False), also as previously suggested you should close the sockets 
that find an open port (sk.close()) inside your while loop.

HTH,
Marty


More information about the Tutor mailing list