在Android系统中进行网络开发时,如果使用了java.nio等相关包后有可能碰到
异常
java.net.SocketException: Bad address family。原因是Android2.2bug不能启用IPV6协议,具体可点击
这里
。
异常信息:
java.net.SocketException: Bad address family at org.apache.harmony.luni.platform.OSNetworkSystem.connectStreamWithTimeoutSocketImpl(Native Method) at org.apache.harmony.luni.platform.OSNetworkSystem.connect(OSNetworkSystem.java:115) at org.apache.harmony.nio.internal.SocketChannelImpl.connect(SocketChannelImpl.java:272) at org.apache.harmony.nio.internal.PipeImpl$SinkChannelImpl.finishConnect(PipeImpl.java:164) at org.apache.harmony.nio.internal.PipeImpl.(PipeImpl.java:48) at org.apache.harmony.nio.internal.SelectorProviderImpl.openPipe(SelectorProviderImpl.java:51) at org.apache.harmony.nio.internal.SelectorImpl.(SelectorImpl.java:141) at org.apache.harmony.nio.internal.SelectorProviderImpl.openSelector(SelectorProviderImpl.java:58)
原文地址:
解决android网络异常java.net.SocketException: Bad address family| http://orgcent.com/android-bad-address-family-exception/