GithubHelp home page GithubHelp logo

funnyyish / hola Goto Github PK

View Code? Open in Web Editor NEW

This project forked from fflewddur/hola

0.0 1.0 0.0 1.76 MB

Hola is a minimalist Java implementation of Multicast DNS Service Discovery (mDNS-SD)

License: MIT License

Java 100.00%

hola's Introduction

Hola Build Status

Hola is a minimalist Java implementation of Multicast DNS Service Discovery (mDNS-SD). The purpose of Hola is to give Java developers a dead-simple API for finding Zeroconf-enabled services on a local network. It follows RFCs 6762 and 6763 and is compatible with Apple's Bonjour mDNS-SD implementation.

Features

Hola is a work-in-progress. The following features are currently supported:

  • Browse (synchronously) for instances of services on a local network
  • Retrieve information about discovered services, including network addresses, ports, and user-friendly names
  • Supports both IPv4 and IPv6 networks

API Example

To search for services, create a Query specifying the type of service you're looking for and the domain to search. You can execute a blocking search with the runOnce() method; this will return a set of Instance objects representing the discovered instances. As an example, the following code will search for TiVo devices on the user's local network:

public class TivoFinder {
    final static Logger logger = LoggerFactory.getLogger(TivoFinder.class);

    public static void main(String[] args) {
        try {
            Service service = Service.fromName("_tivo-mindrpc._tcp");
            Query query = Query.createFor(service, Domain.LOCAL);
            Set<Instance> instances = query.runOnce();
            instances.stream().forEach(System.out::println);
        } catch (UnknownHostException e) {
            logger.error("Unknown host: ", e);
        } catch (IOException e) {
            logger.error("IO error: ", e);
        }
    }
}

Each Instance will have a user-visible name, a set of IP addresses, a port number, and a map of attributes:

String userVisibleName = instance.getName();
Set<InetAddress> addresses = instance.getAddresses();
int port = instance.getPort();
if (instance.hasAttribute("platform")) {
    String platform = instance.lookupAttribute("platform");
}

An asynchronous run() method is planned for performing a continuous service discovery operation, but this feature is not yet implemented.

Requirements

Hola requires Java 8 or higher. It handles logging via SLF4J, so the slf4j-api.jar must also be in your Hola-enabled project's class path.

License

Hola is free software and released under the MIT License.

hola's People

Contributors

derabbink avatar fflewddur avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.