Hola

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

License

License

Categories

Categories

Net
GroupId

GroupId

net.straylightlabs
ArtifactId

ArtifactId

hola
Last Version

Last Version

0.2.3
Release Date

Release Date

Type

Type

jar
Description

Description

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

Project URL

https://github.com/fflewddur/hola
Source Code Management

Source Code Management

https://github.com/fflewddur/hola.git

Download hola

How to add to project

<!-- https://jarcasting.com/artifacts/net.straylightlabs/hola/ -->
<dependency>
    <groupId>net.straylightlabs</groupId>
    <artifactId>hola</artifactId>
    <version>0.2.3</version>
</dependency>
// https://jarcasting.com/artifacts/net.straylightlabs/hola/
implementation 'net.straylightlabs:hola:0.2.3'
// https://jarcasting.com/artifacts/net.straylightlabs/hola/
implementation ("net.straylightlabs:hola:0.2.3")
'net.straylightlabs:hola:jar:0.2.3'
<dependency org="net.straylightlabs" name="hola" rev="0.2.3">
  <artifact name="hola" type="jar" />
</dependency>
@Grapes(
@Grab(group='net.straylightlabs', module='hola', version='0.2.3')
)
libraryDependencies += "net.straylightlabs" % "hola" % "0.2.3"
[net.straylightlabs/hola "0.2.3"]

Dependencies

compile (2)

Group / Artifact Type Version
org.slf4j : slf4j-api jar 1.7.25
ch.qos.logback : logback-classic jar 1.2.3

test (1)

Group / Artifact Type Version
junit : junit jar 4.12

Project Modules

There are no modules declared in this project.

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.

Versions

Version
0.2.3
0.2.2
0.2.1
0.2.0