United StatesChange Country, Oracle Worldwide Web Sites Communities I am a... I want to...
Bug ID: JDK-6206527 "cannot assign address" when binding ServerSocket on Suse 9
JDK-6206527 : "cannot assign address" when binding ServerSocket on Suse 9

Details
Type:
Bug
Submit Date:
2004-12-09
Status:
Resolved
Updated Date:
2011-03-17
Project Name:
JDK
Resolved Date:
2005-04-15
Component:
core-libs
OS:
solaris_9,linux_2.6
Sub-Component:
java.net
CPU:
x86,sparc
Priority:
P3
Resolution:
Fixed
Affected Versions:
5.0
Fixed Versions:

Related Reports
Backport:
Backport:
Duplicate:
Relates:
Relates:

Sub Tasks

Description
When IPv6 is enabled on Suse 9 (or JDS 3) it is not possible
to bind a ServerSocket to the local address.
App receives a "cannot assign requested address" error
###@###.### 2004-12-09 18:17:48 GMT


Just in case.., test case is here:
============ TestCase ===========

import java.net.*;

public class TestServer {

 public static void main(String[] args) throws Exception {

   if (args.length != 2) {
     System.out.println("Usage: java TestServer <host_address_ipv6> <port>");
     System.exit(1);
   }

   System.out.println("Host Address="+args[0]);
   System.out.println("Port        ="+args[1]);

   ServerSocket ss = new ServerSocket();

   ss.bind(new InetSocketAddress(InetAddress.getByName(args[0]), 
  	Integer.parseInt(args[1])));

   System.out.println("ServerSocket Bound");

   ss.accept();
 }
}
java TestServer <host ipv6 address> <port>

for host use local link-local address of the host port 5555

Verify:

On success, the server socket will be bound to the specified address and port. O
n failure some exception will be thrown. For
SuSE Linux ES 9.0, following is thrown:

Exception in thread "main" java.net.BindException: Cannot assign requested addre
ss
        at java.net.PlainSocketImpl.socketBind(Native Method)
        at java.net.PlainSocketImpl.bind(PlainSocketImpl.java:331)
        at java.net.ServerSocket.bind(ServerSocket.java:318)
        at java.net.ServerSocket.bind(ServerSocket.java:276)
        at TestServer.main(TestServer.java:17)

--------------------------------------------------------------------------------
---

System Specification:

java version "1.4.2_05"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.2_05-b04)
Java HotSpot(TM) Client VM (build 1.4.2_05-b04, mixed mode)

SUSE LINUX Enterprise Server 9 (i586) - Kernel 2.6.5-7.97-default (6)
----------------end
###@###.### 2004-12-15 19:15:49 GMT

                                    

Comments
EVALUATION

In the Linux native code, we use the kernel IPv6 routing table
to figure out which scope_id value to use when a given Inet6Address
has no scope_id set. For the local link-local address, this
always points to the "lo" loopback interface, which is correct
for destination addresses, ie. packets are sent out the loopback
interface when the destination is the local LL address. However,
this is not correct when binding to a local address. In this
case, it doesn't make sense to set the scope_id to the loopback
interface because that would seem to preclude binding on physical
interfaces (which is normally what you want to do). This worked
ok on Linux kernels prior to 2.6 because presumably they just ignored
the scope_id setting in the bind() call. Unfortunately, it is broken
now in 2.6.

Linux should allow the application to use a scope_id of zero
which would force the kernel to try an figure out which interface
to use (in most cases it would be possible to determine it).

Since it does not do this, we need to use a different method
for determining the scope_id when binding to a local address.
In this case, we will search /proc/net/if_inet6 instead of 
/proc/net/ipv6_route.
###@###.### 2005-1-04 13:31:44 GMT
                                     
2005-01-04



Hardware and Software, Engineered to Work Together