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

fp.bugs 2500: Win 32 only InetAddress.getHostByAddr() doesn't return name

    Details

    • Subcomponent:
    • Resolved In Build:
      1.0beta2
    • CPU:
      x86
    • OS:
      windows_nt
    • Verification:
      Verified

      Description

      "Robert O'Callahan" <roc+@cs.cmu.edu>

      Win32 only: InetAddress.getHostByAddr() returns ip address string, not the host name.
      It should return host hame. Note: user says it is a problem with byte order of the
      network address. I'm including his entire message in description.

      Steps to reproduce:
      Compile and run this code on a Win 32 machine
      // Note: this creates a server listening to socket 10000
      Connect to the computer that this code is running on via telnet on port 10000
      // Note: the server will print the host name and shut down.



      /* **** Source Code and notes *****

      From roc+@cs.cmu.edu Thu Nov 16 10:26 PST 1995
      X-Sender: ###@###.###
      Mime-Version: 1.0
      Date: Thu, 16 Nov 1995 13:25:56 -0500
      To: "Kevin A. Smith" <Kevina.Smith@Eng>
      From: "Robert O'Callahan" <roc+@cs.cmu.edu>
      Subject: Re: Java bug report: InetAddress.getHostName fails. (2500)

      The argument to gethostbyaddr should be in network byte order, but it isn't.
      (This is Win32 specific because it's an endianness problem.) Anyway here's
      your program. Start it up and then telnet to the machine on port 10000.
      The hostname will not be resolved; the program will print out the dotted IP
      number. I have built a patched version of the runtime - incorporating the
      patch that I mentioned - which, when used to run this program, prints out
      the correct host name of the machine which established the connection.

      */

      import java.net.*;
      import java.io.*;

      public class SockTest
      {
          static public void main(String args[])
          {
             try
             {
                ServerSocket sock = new ServerSocket(10000, 8);
                System.out.println(sock.accept().getInetAddress().getHostName());
             }
             catch (IOException e) { }
          }
      }

        Attachments

          Activity

            People

            • Assignee:
              dconnellsunw David Connelly (Inactive)
              Reporter:
              kasmithsunw Kevin Smith (Inactive)
            • Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:
                Imported:
                Indexed: