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

IOException thrown when Socket tries to bind to an local IPv6 address on SuSE Linux

XMLWordPrintable

    • b13
    • generic, sparc
    • linux, solaris_9
    • Verified

        It seems that the Socket constructor

        public Socket(InetAddress address,
                      int port,
                      InetAddress localAddr,
                      int localPort)

        cannot successfully complete on SuSE Linux. See attached for the test program.

        The program does the following:

        1) Start a test server and use Socket constructor Socket(InetAddress, int) to create a connection and send some data. Both server and client are closed.

        2) Start another test server and use Socket constructor Socket(InetAddress, int, InetAddress, int) to create a connection and send some data.

        It is observed that when an IPv6 address is used in step 2), the Socket creation fails with the following stack trace:

        /java/re/j2se/6.0/archive/fcs/binaries/linux-i586/bin/java -classpath ~/tests IPv6SocketTest fe80:0:0:0:207:e9ff:fe62:7e18
        java.net.BindException: Cannot assign requested address
        at java.net.PlainSocketImpl.socketBind(Native Method)
        at java.net.PlainSocketImpl.bind(PlainSocketImpl.java:359)
        at java.net.Socket.bind(Socket.java:565)
        at java.net.Socket.<init>(Socket.java:364)
        at java.net.Socket.<init>(Socket.java:266)
        at IPv6SocketTest.test2(IPv6SocketTest.java:105)
        at IPv6SocketTest.main(IPv6SocketTest.java:149)
        Exception during creating Socket object java.net.BindException: Cannot assign requested address

        It is also found that if we skip step 1) (by commenting out test1() in main()), the Socket still cannot be created in step 2), but due to timeout instead.

        Here is the network configuration:

        eth0 Link encap:Ethernet HWaddr 00:07:E9:62:7E:18
                  inet addr:129.145.163.163 Bcast:129.145.163.255 Mask:255.255.254.0
                  inet6 addr: fe80::207:e9ff:fe62:7e18/64 Scope:Link
                  UP BROADCAST NOTRAILERS RUNNING MULTICAST MTU:1500 Metric:1
                  RX packets:5919400 errors:27 dropped:0 overruns:0 frame:27
                  TX packets:1425053 errors:1 dropped:0 overruns:0 carrier:1
                  collisions:348412 txqueuelen:1000
                  RX bytes:1694148885 (1615.6 Mb) TX bytes:242995518 (231.7 Mb)
                  Base address:0xcc00 Memory:ff8e0000-ff900000

        lo Link encap:Local Loopback
                  inet addr:127.0.0.1 Mask:255.0.0.0
                  inet6 addr: ::1/128 Scope:Host
                  UP LOOPBACK RUNNING MTU:16436 Metric:1
                  RX packets:93462 errors:0 dropped:0 overruns:0 frame:0
                  TX packets:93462 errors:0 dropped:0 overruns:0 carrier:0
                  collisions:0 txqueuelen:0
                  RX bytes:17620957 (16.8 Mb) TX bytes:17620957 (16.8 Mb)

        Here is the host information:

        Linux d-usca22-163-163 2.6.4-52-smp #1 SMP Wed Apr 7 02:11:20 UTC 2004 i686 i686 i386 GNU/Linux

        It is observed that the problem does not exist if an IPv4 address is used as an argument to the program, or if the program is executed on Solaris.

              yuwangsunw Yujiang Wang (Inactive)
              xwangsunw Xiaozhong Wang (Inactive)
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

                Created:
                Updated:
                Resolved:
                Imported:
                Indexed: