本文介绍了Android 2.2及"坏地址族"在插座连接的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个非常简单的游戏,完美的作品在每个版本现在向上穿过2.1,但随着新的2.2(升级Froyo)版本,我无法创建一个插座。我现在用的一锭银子包NIO,并得到此异常:

I have a fairly simple game that works perfectly on every version now up through 2.1, but with the new 2.2 (Froyo) release I am unable to create a socket. I am using the mina package for nio, and get this exception:

W / System.err的(263): java.net.SocketException异常:错误的地址族  W / System.err的(263):在org.apache.harmony.luni.platform.OSNetworkSystem.connectStreamWithTimeoutSocketImpl(本机方法)  W / System.err的(263):在org.apache.harmony.luni.platform.OSNetworkSystem.connect(OSNetworkSystem.java:115)  W / System.err的(263):在org.apache.harmony.nio.internal.SocketChannelImpl.connect(SocketChannelImpl.java:272)  W / System.err的(263):在org.apache.harmony.nio.internal.PipeImpl $ SinkChannelImpl.finishConnect(PipeImpl.java:164)  W / System.err的(263):在org.apache.harmony.nio.internal.PipeImpl(PipeImpl.java:48)。  W / System.err的(263):在org.apache.harmony.nio.internal.SelectorProviderImpl.openPipe(SelectorProviderImpl.java:51)  W / System.err的(263):在org.apache.harmony.nio.internal.SelectorImpl(SelectorImpl.java:141)。  W / System.err的(263):在org.apache.harmony.nio.internal.SelectorProviderImpl.openSelector(SelectorProviderImpl.java:58)  W / System.err的(263):在java.nio.channels.Selector.open(Selector.java:48)  W / System.err的(263):在org.apache.mina.transport.socket.nio.SocketConnector.startupWorker(SocketConnector.java:248)  W / System.err的(263):在org.apache.mina.transport.socket.nio.SocketConnector.connect(SocketConnector.java:210)  W / System.err的(263):在org.apache.mina.transport.socket.nio.SocketConnector.connect(SocketConnector.java:137)  W / System.err的(263):在org.apache.mina.common.support.BaseIoConnector.connect(BaseIoConnector.java:40)

后来在日志中,通常紧接着我得到这样的:

Later in the log, usually immediately following I get this:

W / System.err的(263):显示java.lang.NullPointerException  W / System.err的(263):在org.apache.harmony.nio.internal.SelectorImpl.wakeup(SelectorImpl.java:418)  W / System.err的(263):在org.apache.mina.transport.socket.nio.SocketConnector.connect(SocketConnector.java:222)  W / System.err的(263):在org.apache.mina.transport.socket.nio.SocketConnector.connect(SocketConnector.java:137)  W / System.err的(263):在org.apache.mina.common.support.BaseIoConnector.connect(BaseIoConnector.java:40)

我已经做了所有谷歌上搜索,并环顾四周,我能想到的,并没有发现什么。我来最接近似乎与XP和Vista的机器支持IPv6(我运行Vista的)一个老JDK错误。建议包括禁用IPv6(没有工作),并禁用IPv4和IPv6的离开(会不会为我工作作为我的路由器和ISP不支持它,所以无论如何也测试)。

I have done all the googling and looking around I can think of and found nothing. The closest I have come seems to be an old JDK bug with ipv6 support on XP and Vista machines (I'm running Vista). Recommendations included disabling ipv6 (that did not work) and disabling ipv4 and leaving ipv6 (will not work for me as my router and ISP don't support it and so could not test anyway).

任何想法,建议,东西我还没有尝试过?

Any thoughts, suggestions, things I have not tried?

谢谢,约什

推荐答案

这是一个错误,并已得到修复:<一href="http://$c$c.google.com/p/android/issues/detail?id=9431">http://$c$c.google.com/p/android/issues/detail?id=9431

this was a bug and has been fixed: http://code.google.com/p/android/issues/detail?id=9431

你应该非常小心的java.net。preferIPv6Addresses的解决方法,因为有设备和网络,你确实需要的IPv6。

you should be very careful with the java.net.preferIPv6Addresses workaround, because there are devices and networks where you do want IPv6.

(和,作为原始海报发现,如果你的可以的使用IO而不是妞妞,你一般的应该的。)

(and, as the original poster found, if you can use io rather than nio, you generally should.)

这篇关于Android 2.2及&QUOT;坏地址族&QUOT;在插座连接的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-02 00:29