ip addfress purpose code example
Example 1: what use of ip addresses
import java.net.InetAddress;
import java.net.UnknownHostException;
public class FindIPaddress {
public static void main(String[] args) throws UnknownHostException {
InetAddress a = InetAddress.getLocalHost();
System.out.println(a.getHostAddress());
}
}
Example 2: type of ip address
Static means the IP address never changes
as long as you stay with the same provider or same server.
Dynamic means the IP address can change from time-to-time.
Public means the IP address can be visited from any computer in the world.
Private means the IP address can only be used by those on the same network.
Shared means other people use your IP address for their connection or websites.
Dedicated means no one else uses your IP address for their connection or websites.
Class identifies the range of your IP address and the default subnet mask.
A class - 0 to 127 with default mask of 255.0.0.0
B class - 128 to 191 with default mask of 255.255.0.0
C class - 192 to 223 with default mask of 255.255.255.0
D class - 224 to 247 (not currently used)
E class - 248 to 255 (not currently used)