networking - small ip scanner code in java -


I am writing a small game in Java, there is a server and client module. At this time every customer must enter the server IP (local network) manually. This is the reason I wrote this code here:

  import java.net *; Public Category IIP {Public Stable Zero Main (String AGR []) {try {InetAddress ownIP = InetAddress.getLocalHost (); String myIP = ownIP.getHostAddress (); System.out.println ("My system has IP: =" + IIP); } Hold (exception e) {System.out.println ("caught the exception =" + e.getMessage ()); }}}   

This piece of code gives the machine's IP address. With this information (My own IP address) I now want to automatically check the server for this other IP address in this category.

Now I do not know how to recurs on this IP range, for example: If "myIP" is 10.0.0.5, then how can I modify that string, for example 10.0 Will be .0.6? If it would be an integer value, then adding 1 to it would be easy every time-- but since it is a string - different from dots - I'm not sure how to solve it :) Any ideas?

Cheers

So, you have to convert an IPv4 address back and back is required.

See if it helps:



Comments