Skip to content

dhufnagel/jmdns

 
 

Repository files navigation

build status

This library is licensed under the Apache License Version 2.0. Please see the file NOTICE.txt.

Arthur van Hoff [email protected]

Rick Blair [email protected]

Kai Kreuzer [email protected]

JmDNS

This is an implemenation of multi-cast DNS in Java. It supports service discovery and service registration. It is fully interoperable with Apple's Bonjour.

Sample Code for Service Registration

    import javax.jmdns.*;

    JmDNS jmdns = new JmDNS();
    jmdns.registerService(
    	new ServiceInfo("_http._tcp.local.", "foo._http._tcp.local.", 1234, 0, 0, "path=index.html")
    );

Sample code for Service Discovery

    import javax.jmdns.*;

    static class SampleListener implements ServiceListener {
    	public void addService(JmDNS jmdns, String type, String name)
    	{
    	    System.out.println("ADD: " + jmdns.getServiceInfo(type, name));
    	}
    	public void removeService(JmDNS jmdns, String type, String name)
    	{
    	    System.out.println("REMOVE: " + name);
    	}
    	public void resolveService(JmDNS jmdns, String type, String name, ServiceInfo info)
    	{
    	    System.out.println("RESOLVED: " + info);
    	}
    }

    JmDNS jmdns = new JmDNS();
    jmdns.addServiceListener("_http._tcp.local.", new SampleListener());

About

Official home of the jmDNS library

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Java 99.1%
  • Other 0.9%