My favorites | Sign in
Project Home Issues
New issue   Search
  Advanced search   Search tips   Subscriptions
Issue 9431: [Android 2.2] Java NIO Selector open fails on devices without IPv6 support (SocketException)
20 people starred this issue and may be notified of changes. Back to list
Status:  Released
Closed:  Aug 2010

  • Only users with Commit permission may comment.

Sign in to add a comment
Reported by, Jun 30, 2010
I developed an application using java NIO, it works fine on Android 2.1.
But the application doesn't work on Android 2.2(Froyo).
The problem is NIO Selector open fail.
Here is logs...
--------- Bad address family
     at org.apache.harmony.luni.platform.OSNetworkSystem.connectStreamWithTimeoutSocketImpl(Native Method)
     at org.apache.harmony.luni.platform.OSNetworkSystem.connect(
     at org.apache.harmony.nio.internal.SocketChannelImpl.connect(
     at org.apache.harmony.nio.internal.PipeImpl$SinkChannelImpl.finishConnect(
     at org.apache.harmony.nio.internal.PipeImpl.<init>(
     at org.apache.harmony.nio.internal.SelectorProviderImpl.openPipe(
     at org.apache.harmony.nio.internal.SelectorImpl.<init>(
     at org.apache.harmony.nio.internal.SelectorProviderImpl.openSelector(
     at com.sejin.NwTestActivity.onCreate(
     at android.os.Handler.dispatchMessage(
     at android.os.Looper.loop(
     at java.lang.reflect.Method.invokeNative(Native Method)
     at java.lang.reflect.Method.invoke(
     at dalvik.system.NativeStart.main(Native Method)

I did googling, someone said JRE 1.6 bug on Vista or address problem between IPv4 and IPv6. But i don't think that.
First, My environment is not VISTA.
Second, as the logs I just open NIO selector not connecting to some addresses.

Jun 30, 2010
My code is simple..

Selector mySelector =;

I tried this code below, but the result was same

AbstractSelector mySelector = SelectorProvider.provider().openSelector();
Jul 1, 2010
Project Member #2
this is on the emulator? the emulator doesn't support IPv6.
Labels: Component-Dalvik
Jul 1, 2010
I have a test device that doesn't start to release. It's OS is Froyo and this situation is same. As you comment, the problem is the device doesn't support IPv6. 
I wonder how can a application detact it's device support IPv6 or not. 
Is there a way that I can use Java NIO(specially Selector), if the device support IPv6 or not?
Jul 2, 2010
Project Member #4
i believe you can't pass CTS without IPv6 support, so it might be easiest if you just hassle your kernel guys right away.

we have a bug to rewrite Pipe to not use an internet socket at all, but that doesn't help you right now.

if you want a hack so you can get some work done while you wait for your kernel guys, i'd suggest you look at PipeImpl; if you had an InetSocketAddress whose InetAddress was the IPv4 loopback address rather than the IPv6 loopback address it currently asks for...
Jul 4, 2010
thank you for comments.

Could you tell me, when does the bug fix in Android 2.2? Do you have some plan?
If the bug remains in Android 2.2, application developers can't use Java NIO (Selector), I think. At least, you should recommand this to Selector reference pages on Android reference site.

Jul 5, 2010
I also have Selector issues while working with Froyo. The system will throw a NullPointerException when i try to call Selector.wakeup(), but the same code works perfect in all previous releases on Android platform.

It seems that Froyo has some bugs in its selector implementation.
Jul 7, 2010
Project Member #7
@5: rewriting Pipe to not use an internet socket will not happen in froyo. i don't know what release it will happen in. developers can still use Selector; they just need an IPv6-enabled kernel. all devices need an IPv6-enabled kernel to pass CTS anyway.

@6: please file a separate bug with a reproduceable test case.
Summary: [Android 2.2] Java NIO Selector open fails on devices without IPv6 support (SocketException)
Jul 8, 2010
My device does not support ipv6, the following works for me (YMMV/nothing guaranteed/...)

Change vm/Properties.c
 setProperty(propObj, put, "", "true");
 setProperty(propObj, put, "", "false");

If CTS passing is needed for you, you still have a problem.
Aug 3, 2010
Project Member #9
fixed internally to use pipe(2) rather than an internet socket.
Status: FutureRelease
Nov 30, 2010
work around:

    		java.lang.System.setProperty("", "true");
    		java.lang.System.setProperty("", "false");

Dec 6, 2010
Project Member #11
(No comment was entered for this change.)
Status: Released
Labels: Target-Gingerbread
Dec 3, 2012
Project Member #12
(No comment was entered for this change.)
Labels: Restrict-AddIssueComment-Commit
Sign in to add a comment

Powered by Google Project Hosting