Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-4215759

getHostByName() returns IP address with Multicast IP addresses

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Not an Issue
    • Icon: P4 P4
    • None
    • 1.2.0
    • core-libs
    • x86
    • windows_95



      Name: dbT83986 Date: 02/27/99


      Passing InetAddress.getByName() an IP address of a Multicast
      host (i.e. 224.0.1.25 - NBC-PRO.MCAST.NET) returns an InetAddress
      object with the host name field the same as the IP address in
      JDK2. There was a bug fix in 1.1 that addressed this problem,
      but apparently something in JDK2 broke it for multicast addresses,
      as getByName() works in JDK1.1.7B even if the IP address is
      a multicast host. Run the following code and supply 224.0.1.25
      as the command line arg under 1.2 and 1.1.7:

        import java.net.*;

      class getNameByIP {

      public static void main (String args[]) {

          String s = null;
          InetAddress address = null;

          if (args.length > 0) {
            try {
              s = args[0];
              address = InetAddress.getByName(s);
              System.out.println(address);
            }
            catch (UnknownHostException e) {
              System.err.println(e);
            }
          }
          else {
            System.out.println("USAGE: java getNameByIP XX.XX.XX.XX");
          }
        }
      }

      Here is the output from JDK1.2:

      c:\jdk1.2\bin\java.exe getNameByIP 224.0.1.25
      Working Directory - C:\NICKPRGS\JAVA\netprog\chap13Class Path - c:\nickprgs\java\brazziel\;.;C:\Program Files\Kawa\classes.zip;c:\jdk1.2\lib\tools.jar;c:\jdk1.2\jre\lib\rt.jar
      224.0.1.25/224.0.1.25



      Here is the output from JDK1.1.7B:

      c:\jdk1.1.7B\bin\java.exe getNameByIP 224.0.1.25
      Working Directory - C:\NICKPRGS\JAVA\netprog\chap13Class Path - c:\nickprgs\java\brazziel\;.;C:\Program Files\Kawa\classes.zip;c:\jdk1.1.7b\lib\classes.zip
      NBC-PRO.MCAST.NET/224.0.1.25

      Process Exit...
      (Review ID: 52276)
      ======================================================================

            ywangsunw Yingxian Wang (Inactive)
            dblairsunw Dave Blair (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: