Slip No 11 Q A

Write a java program to display IPAddress and name of client machine.

import java.net.InetAddress;

public class ClientInfo {

    public static void main(String[] args) {
        try {
            // Get local host information
            InetAddress inet = InetAddress.getLocalHost();

            // Display client machine details
            System.out.println("Client Machine Name : " + inet.getHostName());
            System.out.println("Client IP Address   : " + inet.getHostAddress());

        } catch (Exception e) {
            System.out.println(e);
        }
    }
}
Spread the love

Leave a Comment

Your email address will not be published. Required fields are marked *

Scroll to Top