Advertisement
iPeer

Untitled

Sep 13th, 2012
71
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.47 KB | None | 0 0
  1.     private static int getPort(String addr) {
  2.         try {
  3.             Hashtable a = new Hashtable();
  4.             a.put("java.naming.factory.initial", "com.sun.jndi.dns.DnsContextFactory");
  5.             a.put("java.naming.provider.url", "dns:");
  6.             InitialDirContext b = new InitialDirContext(a);
  7.             Attributes c = b.getAttributes("_minecraft._tcp."+addr, new String[] {"SRV"});
  8.             return Integer.parseInt(c.get("srv").get().toString().split(" ", 4)[2]);
  9.         }
  10.         catch (Exception e) {
  11.             return 25565;
  12.         }
  13.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement