Menu

#8 Research Network Monitoring (Gather Device Info)

1.0
open
None
2014-02-01
2014-01-30
No

Research to see if the following is possible using Java (or at all).

  1. Gather information from connected devices (Name/IP/etc).

Identify any library or resources needed and save information here if possible.

Discussion

  • Yiyang Pan

    Yiyang Pan - 2014-02-01
    1. find out the ip address of the machine you want to send messages to through cmd

    cmd : ipconfig

     
  • Yiyang Pan

    Yiyang Pan - 2014-02-01

    2 How to get Ip address using java

    Enumeration e=NetworkInterface.getNetworkInterfaces();
    while(e.hasMoreElements())
    {
    NetworkInterface n=(NetworkInterface) e.nextElement();
    Enumeration ee = n.getInetAddresses();
    while(ee.hasMoreElements())
    {
    InetAddress i= (InetAddress) ee.nextElement();
    System.out.println(i.getHostAddress());
    }
    }

    http://stackoverflow.com/questions/9481865/how-to-get-ip-address-of-our-own-system-using-java

     

    Last edit: Yiyang Pan 2014-02-01
  • Yiyang Pan

    Yiyang Pan - 2014-02-01

    3 How to get computer name using java

    There's no universal concept of a computer name across OSes, but DNS is generally available. If the computer name hasn't been configured so DNS can resolve it, it isn't available.

    String hostname = "Unknown";

    try
    {
    InetAddress addr;
    addr = InetAddress.getLocalHost();
    hostname = addr.getHostName();
    }
    catch (UnknownHostException ex)
    {
    System.out.println("Hostname can not be resolved");
    }

    http://stackoverflow.com/questions/7883542/getting-the-computer-name-in-java

     

Log in to post a comment.