Samples with JmDNS

后端 未结 1 1689
忘掉有多难
忘掉有多难 2021-02-09 15:34

I\'ve been able to get the samples that come with JmDNS to compile and run, however I can\'t get any of the classes to discover my services.

I\'m running a Windows envir

1条回答
  •  北海茫月
    2021-02-09 15:49

    To discover a specific type of service, you need to know the correct service type name, check out DNS SRV (RFC 2782) Service Types:

    String bonjourServiceType = "_http._tcp.local.";
    bonjourService = JmDNS.create();
    bonjourService.addServiceListener(bonjourServiceType, bonjourServiceListener);
    ServiceInfo[] serviceInfos = bonjourService.list(bonjourServiceType);
    for (ServiceInfo info : serviceInfos) {
      System.out.println("## resolve service " + info.getName()  + " : " + info.getURL());
    }
    bonjourService.close();
    

    For VNC, use _rfb._tcp.local.
    For SSH, use _ssh._tcp.local.
    For Apache, use _http._tcp.local.

    0 讨论(0)
提交回复
热议问题