On 09/02/2011 12:58 PM, Charles Lee wrote:
On 09/02/2011 12:50 PM, Charles Lee wrote:
Hi guys,

In some linuxes, when you bind on a loopback network interface, sendto will be fail and errono will be set to EHOSTUNREACH. In this situation, EHOSTUNREACH maybe need treat as INVAL: return false, not throw an exception.

Patch is attached.

Does anyone interested in this issue?


Sorry, I attached a wrong diff. Here is the right one.

Hi guys,

I'd like to raise this issue again. The patch is on the [1]:

When a loopback network interface is bound to sendto and connect, in some linuxes it will throw an EINVAL errno, in other linuxes (AIX, iSeries) it will throw an EHOSTUNREACH errno. The man page of sendto on Aix and solaris is [2][3]. In such situation, EHOSTUNREACH should treat as the same as EINVAL: not throw an exception but return false.

Below is the simple test case can test this situation in specific platforms:

/public class IsReachableTest {
    public static void main(String[] args) throws Exception{
        InetAddress testHost1 = InetAddress.getByName("openjdk.java.net");
        NetworkInterface loopbackNi = null;
Enumeration<NetworkInterface> list = NetworkInterface.getNetworkInterfaces();
        boolean loopbackFound = false;
        while (list.hasMoreElements() && !loopbackFound){
            loopbackNi = list.nextElement();
            if (loopbackNi.isLoopback() && loopbackNi.isUp()) {
                loopbackFound = true;
            }
        }

        if (!loopbackFound)
            return;
        if (testHost1.isReachable(loopbackNi, 64, 1000))
System.out.println(String.format("Fail: external host '%s' is reachable via loopback '%s'!",
                                             testHost1, loopbackNi));
    }
}/

Any thoughts, guys?


[1] http://cr.openjdk.java.net/~littlee/OJDK-175/webrev.00/ <http://cr.openjdk.java.net/%7Elittlee/OJDK-175/webrev.00/> [2] http://publib.boulder.ibm.com/infocenter/aix/v6r1/index.jsp?topic=%2Fcom.ibm.aix.commtechref%2Fdoc%2Fcommtrf2%2Fsendto.htm
[3] http://man-wiki.net/index.php/2:sendto

--
Yours Charles

Reply via email to