M
Markus Kern
Hey,
i am coding a simple port scanner.
now i want to make it scan a whole range of ip numbers. how can i
increment the datatype InetAddress? i checked all it's methodes, but
i can't see a nice solution for that. you could cast it to string and split
it into int octets, but thats not really nice i think.
then i thought about the getAddress methode, but look at this code:
public class test {
public static void main(String[] args) throws UnknownHostException {
InetAddress test = null;
test = InetAddress.getByName("200.120.254.255");
byte[] ip = test.getAddress();
for (int i = 0; i<ip.length; i++)
System.out.println (ip);
}
}
output:
-56
120
-2
-1
so this dosn't help me really - i thought i get the real octets then and could write
a methode to inc them, but like this i don't really know what to do.
i think you understood my problem.
maybe someone has a nice solution for this.
(btw i googeled alot for ip/port scanner java source code - but couldn't find help
do you got a hint where to find code snipplets etc)
thanx in advance.
markus
i am coding a simple port scanner.
now i want to make it scan a whole range of ip numbers. how can i
increment the datatype InetAddress? i checked all it's methodes, but
i can't see a nice solution for that. you could cast it to string and split
it into int octets, but thats not really nice i think.
then i thought about the getAddress methode, but look at this code:
public class test {
public static void main(String[] args) throws UnknownHostException {
InetAddress test = null;
test = InetAddress.getByName("200.120.254.255");
byte[] ip = test.getAddress();
for (int i = 0; i<ip.length; i++)
System.out.println (ip);
}
}
output:
-56
120
-2
-1
so this dosn't help me really - i thought i get the real octets then and could write
a methode to inc them, but like this i don't really know what to do.
i think you understood my problem.
maybe someone has a nice solution for this.
(btw i googeled alot for ip/port scanner java source code - but couldn't find help
do you got a hint where to find code snipplets etc)
thanx in advance.
markus