01: /**
02:  * Verilen baslangic ve bitis araligindaki IP'lere ulasilip,
03:  * ulasilmadigina bakar.
04:  * @author aatay EB
05:  * @version 1.2
06:  */
07: public class PingThread extends Thread{
08: 
09:         //Aralik taramasindaki baslangic ve bitis adresi
10:         private String ip_range_beginning;
11:         private String ip_range_end;
12:         private StringBuffer total_result;
13:         private StringBuffer local_result = new StringBuffer();
14: 
15:     /**
16:          * PingThread ayarlamalarini yapar.
17:          * @param ip_range_begin Taramada kullanilacak baslangic adresi
18:          * @param ip_range_end Taramada kullanilacak bitis adresi
19:          */
20:         public PingThread(String ip_range_begin,
21:                         String ip_range_end,StringBuffer total_result) {
22:                 this.ip_range_beginning = ip_range_begin.trim();
23:                 this.ip_range_end = ip_range_end.trim();
24:                 this.total_result = total_result;
25:     }
26:         /**
27:          * IP taramasini thread olarak yapar.
28:          */
29:         public void run() {
30:  
31:                 String temp_beginning = ip_range_beginning;
32:                 while( !BasicIPTools.check_equality(ip_range_beginning,
33:                                 ip_range_end) ) {
34:                         if( ip_range_beginning.endsWith("0")||
35:                                         ip_range_beginning.endsWith("255") )
36:                         {
37:                                 ip_range_beginning =
38:                                         BasicIPTools.increase_IP(ip_range_beginning);
39:                                 continue;
40:                         }
41:                         try {
42:                                 if(Pinger.windows_ping(ip_range_beginning))
43:                                         local_result.append(ip_range_beginning+"\t\tUlasilabilir!\n");
44:                         } catch (Exception e) { }
45:                         ip_range_beginning =
46:                                 BasicIPTools.increase_IP(ip_range_beginning);
47:                         }
48:                         try {
49:                                 if( Pinger.windows_ping(ip_range_beginning) )
50:                                         local_result.append(ip_range_beginning+"\t\tUlasilabilir!\n");
51:                         } catch (Exception e) {}
52:                         if(local_result.toString()!=null) local_result.append("\n");
53:                         total_result.append(temp_beginning+" - "+
54:                                 ip_range_end + " arasi tamamlanmistir!\n"+local_result);
55:         }
56: 
57:         public static void main(String arg[]) {
58:                 PingThread a[] = new PingThread[5];
59:                 /*a[0] = new PingThread("10.0.0.0","10.0.0.3");
60:                 a[0].start();*/
61:         }
62: 
63: }