|
How to determine the IP address and hostname of the local machine |
|
|
This Java tip demonstrates a method of determining the IP address and hostname of
the local machine. Developer may use this for internal processing in their
applications. This may be implemented on the client side to send the IP address
and their hostname to the server.
try {
InetAddress addr = InetAddress.getLocalHost();
// Get IP Address
byte[] ipAddr = addr.getAddress();
// Get hostname
String hostname = addr.getHostName();
} catch (UnknownHostException e) {
}
|
Related Tips
|
Page 1 of 0 ( 0 comments )
You can share your information about this topic using the form below!
Please do not post your questions with this form! Thanks.