java - Multi Threaded Port Scanner, scanning multiple IP's. How can I ensure that the ip's are scanned one at a time -


i building port scanner can scan ip range. have got point parameters correct , multithread port scanner works single ip, problem have when trying scan range of ip's starts of x number of multithreaded scanners (x being number of ip's) @ same time , of course causing memory problems. wondering how threadpools run sequentially. scanning single ip @ time in order.

this code have defining list of ip addresses , putting them multithread scanner.

        else if (chkiprange.isselected()==true){         system.out.println("multi ip scan started");         if(multiscanner==null && errorcheck()==0 || isscanning==false){             isscanning=true;             lstmessagesmodel.clear();             listlisteningmodel.clear();             btnscan.settext("stop");             lstmessagesmodel.addelement("scan started...");             int p1 = integer.parseint(txtstartport.gettext());             int p2 = integer.parseint(txtfinalport.gettext());              try {                 inetaddress ip1 = inetaddress.getbyname(txttargetip.gettext());                 inetaddress ip2 = inetaddress.getbyname(txtfiniship.gettext());                 list<inetaddress> iplist = new arraylist<inetaddress>();                  int ip1int = bytebuffer.wrap(ip1.getaddress()).getint();                 int ip2int = bytebuffer.wrap(ip2.getaddress()).getint();                  (int = ip1int; <= ip2int; i++) {                     inetaddress ipname = inetaddress.getbyname(string.valueof(i));                     iplist.add(ipname);                     system.out.println(ipname);                 }                 (inetaddress ipsingle : iplist) {                     multiscanner = new multithread(ipsingle, p1, p2, this);                     multiscanner.start();                     system.out.println("new thread started");                 }              } catch (unknownhostexception e) {                 lstmessagesmodel.addelement("unable connect");             }         }     } 

i can see creating new instance of multithread scanner each ip address , root of problem, unsure how send new ip address scanner without creating new instance?

thank


Comments

Popular posts from this blog

curl - PHP fsockopen help required -

HTTP/1.0 407 Proxy Authentication Required PHP -

c# - Resource not found error -