axis-java-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Ali, Haneef" <haneef....@hp.com>
Subject Multiple network interface
Date Wed, 18 Jul 2007 19:49:02 GMT
Hi,

In my machine I have multiple network interface. (i.e) I have installed
vmware so it shows multiple network interfaces.  How to make axis2 get
the IP address of the correct intefaces?

Ex:  Code from org.apache.axis2.transport.http.sever.HTTPUtils.java

public static String getIpAddress() throws SocketException {
        Enumeration e = NetworkInterface.getNetworkInterfaces();
        String address = "127.0.0.1";

        while (e.hasMoreElements()) {
            NetworkInterface netface = (NetworkInterface)
e.nextElement();
            Enumeration addresses = netface.getInetAddresses();

            while (addresses.hasMoreElements()) {
                InetAddress ip = (InetAddress) addresses.nextElement();
                if (!ip.isLoopbackAddress() &&
isIP(ip.getHostAddress())) {
                    return ip.getHostAddress();
                }
            }
        }

        return address;
    }


This code returns the first available intefaces ipaddress which may not
be the desired ip address? Is there a configuration setting to fix this?

You will have the same problem if you have both lan and wireless
connections. 

Haneef

---------------------------------------------------------------------
To unsubscribe, e-mail: axis-user-unsubscribe@ws.apache.org
For additional commands, e-mail: axis-user-help@ws.apache.org


Mime
View raw message