Querying the DNS service records to find the hostname and TCP/IP

后端 未结 4 1423
无人及你
无人及你 2021-01-02 18:47

In a paper about the Life Science Identifiers (see LSID Tester, a tool for testing Life Science Identifier resolution services), Dr Roderic DM Page wrote :

4条回答
  •  心在旅途
    2021-01-02 19:27

    The JNDI DNS provider can lookup SRV records. You need to do something like:

    Hashtable env = new Hashtable();
    env.put("java.naming.factory.initial", "com.sun.jndi.dns.DnsContextFactory");
    env.put("java.naming.provider.url", "dns:");
    DirContext ctx = new InitialDirContext(env);
    Attributes attrs = ctx.getAttributes("_lsid._tcp.ubio.org", new String[] { "SRV" });
    

    The returned attributes are an enumeration of strings that look like "1 0 80 ANIMALIA.ubio.org". The space separated fields are in order:

    1. priority
    2. weight
    3. port
    4. server

提交回复
热议问题