Re: [Tutor] 3 questions for my port scanner project

2005-02-27 Thread Shitiz Bansal


 2. I got a while loop which does the port scan
 itself. How can I end
 it while its working ?

using the break statement anywhere inside the loop
will exit the loop.

 3. For some reason the scan is too slow (2-3 seconds
 for a port). Is
 there a way to make it faster (other port scanner
 work allot faster...

The ports which do not respond are the ones which take
most of the time.You can use the timer object to fix
the time for each port.For eg. if a port does not
respond within .1 sec it can reasonably be expected to
be closed.The exact implementation will depend upon
your code.You can also use threads to ping more than
one port simultaneously.

And I loved your microsoft quote :).

Cheers
 -- 
 1. The day Microsoft makes something that doesn't
 suck is probably the
 day they start making vacuum cleaners.
 2. Unix is user friendly - it's just picky about
 it's friends.
 3. Documentation is like sex: when it is good, it is
 very, very good.
 And when it is bad, it is better than nothing. -
 Dick Brandon
 ___
 Tutor maillist  -  Tutor@python.org
 http://mail.python.org/mailman/listinfo/tutor
 




__ 
Do you Yahoo!? 
Read only the mail you want - Yahoo! Mail SpamGuard. 
http://promotions.yahoo.com/new_mail 
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] 3 questions for my port scanner project

2005-02-27 Thread Mark Kels
On Sun, 27 Feb 2005 03:24:07 -0800 (PST), Shitiz Bansal
[EMAIL PROTECTED] wrote:
 
 The ports which do not respond are the ones which take
 most of the time.You can use the timer object to fix
 the time for each port.For eg. if a port does not
 respond within .1 sec it can reasonably be expected to
 be closed.The exact implementation will depend upon
 your code.You can also use threads to ping more than
 one port simultaneously.
 
Thank you very much for yuor help !!
Now I only need to figure out how to make a progress bar and my
trubles are over :)

-- 
1. The day Microsoft makes something that doesn't suck is probably the
day they start making vacuum cleaners.
2. Unix is user friendly - it's just picky about it's friends.
3. Documentation is like sex: when it is good, it is very, very good.
And when it is bad, it is better than nothing. - Dick Brandon
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] 3 questions for my port scanner project

2005-02-27 Thread Alan Gauld
  Use a canvas and redraw a rectangle slightly larger every
  time through the scanning loop.

 Thats think this is the easy part...
 The hard part is to make the bar move with the program (so every
 port it finishes the bar will slightly move, which depends on the
 total number of ports to scan...).

But since you know the range of ports you can calculate the total
number. If you keep a count of how many scanned you can work out
the percentage scanned. You then draw a rectangle the same percentage
of the total width. After each port scanned recalculate the
percentage and redraw the rectangle.

Where's the problem? :-)

Alan G.

___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] 3 questions for my port scanner project

2005-02-26 Thread Martin Walsh
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
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor