Skip to content

Commit

Permalink
Apparently MDNS client only applications can query from any port, 535…
Browse files Browse the repository at this point in the history
…3 not required.

Also fix reflection related bug that happens in Android N due to internal method protection level change.
  • Loading branch information
koush committed Jun 10, 2016
1 parent 9c5af48 commit 718f9ab
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions AndroidAsync/src/com/koushikdutta/async/dns/Dns.java
Original file line number Diff line number Diff line change
Expand Up @@ -103,11 +103,11 @@ public static Future<DnsResponse> lookup(AsyncServer server, String host, final
}
else {
// System.out.println("multicast dns...");
dgram = AsyncServer.getDefault().openDatagram(new InetSocketAddress(5353), true);
dgram = AsyncServer.getDefault().openDatagram(new InetSocketAddress(0), true);
Field field = DatagramSocket.class.getDeclaredField("impl");
field.setAccessible(true);
Object impl = field.get(dgram.getSocket());
Method method = impl.getClass().getMethod("join", InetAddress.class);
Method method = impl.getClass().getDeclaredMethod("join", InetAddress.class);
method.setAccessible(true);
method.invoke(impl, InetAddress.getByName("224.0.0.251"));
((DatagramSocket)dgram.getSocket()).setBroadcast(true);
Expand Down

0 comments on commit 718f9ab

Please sign in to comment.