Hi,
I use dnsjnio for resolve dns with application android. I have a problem with version <= android 2.2. It's doesn't work.
The same code works with android 2.3.
My code is not complicated :
ArrayList<String> toResolve = new ArrayList<String>();
toResolve.add("google.fr");
toResolve.add("yahoo.fr");
toResolve.add("bing.fr");
resolver.setTimeout(this.timeOut); resolver.setTCP(true); resolver.setSingleTcpPort(true); ResponseQueue responseQueue = new ResponseQueue(); for (int i = 0; i < toResolve.size(); i++) { String nextName = (String) (toResolve.get(i)); Integer id = new Integer(i); resolver.sendAsync(makeQuery(nextName, i), id, responseQueue); } for (int i = 0; i < toResolve.size(); i++) { Response response = responseQueue.getItem(); if( response!=null && !response.isException() &&response.getMessage().sectionToString(Section.ANSWER) != "") { ............... } }
This is error with TCP :
11-04 21:23:51.655: W/System.err(1378): java.nio.channels.IllegalSelectorException
11-04 21:23:51.655: W/System.err(1378): at java.nio.channels.spi.AbstractSelectableChannel.register(AbstractSelectableChannel.java:158)
11-04 21:23:51.655: W/System.err(1378): at java.nio.channels.SelectableChannel.register(SelectableChannel.java:158)
11-04 21:23:51.655: W/System.err(1378): at uk.nominet.dnsjnio.TCPConnection.connect(Unknown Source)
11-04 21:23:51.655: W/System.err(1378): at uk.nominet.dnsjnio.Connection$1.run(Unknown Source)
11-04 21:23:51.665: W/System.err(1378): at uk.nominet.dnsjnio.DnsController.selectLoop(Unknown Source)
11-04 21:23:51.665: W/System.err(1378): at uk.nominet.dnsjnio.DnsController.access$000(Unknown Source)
11-04 21:23:51.665: W/System.err(1378): at uk.nominet.dnsjnio.DnsController$1.run(Unknown Source)
Same error for UDP :
11-04 20:46:37.225: W/System.err(1342): java.nio.channels.IllegalSelectorException
11-04 20:46:37.225: W/System.err(1342): at java.nio.channels.spi.AbstractSelectableChannel.register(AbstractSelectableChannel.java:158)
11-04 20:46:37.225: W/System.err(1342): at java.nio.channels.SelectableChannel.register(SelectableChannel.java:158)
11-04 20:46:37.225: W/System.err(1342): at uk.nominet.dnsjnio.UDPConnection.connect(Unknown Source)
11-04 20:46:37.225: W/System.err(1342): at uk.nominet.dnsjnio.Connection$1.run(Unknown Source)
11-04 20:46:37.225: W/System.err(1342): at uk.nominet.dnsjnio.DnsController.selectLoop(Unknown Source)
11-04 20:46:37.225: W/System.err(1342): at uk.nominet.dnsjnio.DnsController.access$000(Unknown Source)
11-04 20:46:37.225: W/System.err(1342): at uk.nominet.dnsjnio.DnsController$1.run(Unknown Source)
Hi -
Thanks for the report.
It looks like there was a bug with NIO in android 2.2, which has been fixed with android 2.3. See :
http://lists.jboss.org/pipermail/netty-users/2009-January/000221.html
I think the solution is to avoid android 2.2 - sorry!
Thanks,
Alex.