/[classpath]/classpath/java/net/InetAddress.java
ViewVC logotype

Diff of /classpath/java/net/InetAddress.java

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.31.2.4 by gnu_andrew, Sun Mar 13 14:38:41 2005 UTC revision 1.31.2.5 by gnu_andrew, Mon Apr 18 01:37:38 2005 UTC
# Line 38  exception statement from your version. * Line 38  exception statement from your version. *
38    
39  package java.net;  package java.net;
40    
 import gnu.classpath.Configuration;  
   
41  import java.io.IOException;  import java.io.IOException;
42  import java.io.ObjectInputStream;  import java.io.ObjectInputStream;
43  import java.io.ObjectOutputStream;  import java.io.ObjectOutputStream;
# Line 122  public class InetAddress implements Seri Line 120  public class InetAddress implements Seri
120    
121    static    static
122    {    {
     // load the shared library needed for name resolution  
     if (Configuration.INIT_LOAD_LIBRARY)  
       System.loadLibrary("javanet");  
       
123      // Look for properties that override default caching behavior      // Look for properties that override default caching behavior
124      cache_size =      cache_size =
125        Integer.getInteger("gnu.java.net.dns_cache_size", DEFAULT_CACHE_SIZE)        Integer.getInteger("gnu.java.net.dns_cache_size", DEFAULT_CACHE_SIZE)
# Line 378  public class InetAddress implements Seri Line 372  public class InetAddress implements Seri
372    
373      try      try
374        {        {
375          hostName = getHostByAddr(addr);          hostName = VMInetAddress.getHostByAddr(addr);
376          return hostName;          return hostName;
377        }        }
378      catch (UnknownHostException e)      catch (UnknownHostException e)
# Line 671  public class InetAddress implements Seri Line 665  public class InetAddress implements Seri
665        return addresses;        return addresses;
666    
667      // Not in cache, try the lookup      // Not in cache, try the lookup
668      byte[][] iplist = getHostByName(hostname);      byte[][] iplist = VMInetAddress.getHostByName(hostname);
669    
670      if (iplist.length == 0)      if (iplist.length == 0)
671        throw new UnknownHostException(hostname);        throw new UnknownHostException(hostname);
# Line 762  public class InetAddress implements Seri Line 756  public class InetAddress implements Seri
756    {    {
757      if (inaddr_any == null)      if (inaddr_any == null)
758        {        {
759          byte[] tmp = lookupInaddrAny();          byte[] tmp = VMInetAddress.lookupInaddrAny();
760          inaddr_any = new Inet4Address(tmp, null);          inaddr_any = new Inet4Address(tmp, null);
761        }        }
762    
# Line 770  public class InetAddress implements Seri Line 764  public class InetAddress implements Seri
764    }    }
765    
766    /**    /**
    * This native method looks up the hostname of the local machine  
    * we are on.  If the actual hostname cannot be determined, then the  
    * value "localhost" will be used.  This native method wrappers the  
    * "gethostname" function.  
    *  
    * @return The local hostname.  
    */  
   private static native String getLocalHostname();  
   
   /**  
767     * Returns an InetAddress object representing the address of the current     * Returns an InetAddress object representing the address of the current
768     * host.     * host.
769     *     *
# Line 790  public class InetAddress implements Seri Line 774  public class InetAddress implements Seri
774     */     */
775    public static InetAddress getLocalHost() throws UnknownHostException    public static InetAddress getLocalHost() throws UnknownHostException
776    {    {
777      String hostname = getLocalHostname();      String hostname = VMInetAddress.getLocalHostname();
778      return getByName(hostname);      return getByName(hostname);
779    }    }
780    
   /**  
    * Returns the value of the special address INADDR_ANY  
    */  
   private static native byte[] lookupInaddrAny() throws UnknownHostException;  
   
   /**  
    * This method returns the hostname for a given IP address.  It will  
    * throw an UnknownHostException if the hostname cannot be determined.  
    *  
    * @param ip The IP address as a byte array  
    *  
    * @return The hostname  
    *  
    * @exception UnknownHostException If the reverse lookup fails  
    */  
   private static native String getHostByAddr(byte[] ip)  
     throws UnknownHostException;  
   
   /**  
    * Returns a list of all IP addresses for a given hostname.  Will throw  
    * an UnknownHostException if the hostname cannot be resolved.  
    */  
   private static native byte[][] getHostByName(String hostname)  
     throws UnknownHostException;  
   
781    /*    /*
782     * Needed for serialization     * Needed for serialization
783     */     */

Legend:
Removed from v.1.31.2.4  
changed lines
  Added in v.1.31.2.5

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26