You are viewing a plain text version of this content. The canonical link for it is here.
Posted to rpc-dev@xml.apache.org by dl...@apache.org on 2002/10/10 01:52:53 UTC

cvs commit: xml-rpc/src/java/org/apache/xmlrpc WebServer.java

dlr         2002/10/09 16:52:53

  Modified:    src/java/org/apache/xmlrpc WebServer.java
  Log:
  If an address to bind our listener socket to is not specified, try
  harder to bind to the loopback interface rather than to a random
  network interface at the beginning of the setupServerSocket(int)
  method.
  
  Revision  Changes    Path
  1.19      +12 -1     xml-rpc/src/java/org/apache/xmlrpc/WebServer.java
  
  Index: WebServer.java
  ===================================================================
  RCS file: /home/cvs/xml-rpc/src/java/org/apache/xmlrpc/WebServer.java,v
  retrieving revision 1.18
  retrieving revision 1.19
  diff -u -u -r1.18 -r1.19
  --- WebServer.java	26 Aug 2002 17:41:57 -0000	1.18
  +++ WebServer.java	9 Oct 2002 23:52:53 -0000	1.19
  @@ -248,7 +248,18 @@
           InetAddress addr = address;
           if (addr == null)
           {
  -            addr = InetAddress.getLocalHost();
  +            InetAddress[] addrs = InetAddress.getAllByName("127.0.0.1");
  +            if (addrs.length > 0 &&
  +                "127.0.0.1".equals(addrs[0].getHostAddress()))
  +            {
  +                addr = addrs[0];
  +            }
  +            else
  +            {
  +                // This is not necessarilly the loopback interface -- it
  +                // could be one of your external network interfaces.
  +                addr = InetAddress.getLocalHost();
  +            }
           }
   
           // Since we can't reliably set SO_REUSEADDR until JDK 1.4 is