How to get jmDNS ServiceInfo description string

242 Views Asked by At

How to get description string of jmDNS ServiceInfo whitch we specify in 4 parameters of this overload:

ServiceInfo mServiceInfo = ServiceInfo.create(TYPE, SERVICE_NAME, PORT, DESCRIPTION);

What method can I get value from DESCRIPTION variable of this instance.

Thanks in advance, regards...)

1

There are 1 best solutions below

0
gsflinchum On BEST ANSWER

The following website has the documentation for the ServiceInfo class. http://jmdns.sourceforge.net/apidocs/javax/jmdns/ServiceInfo.html

The method you're looking for is ServiceInfo.getNiceTextString(), which "Returns a description of the service info suitable for printing." This method returns the entire DESCRIPTION variable in a printable string. You can also use the getPropertyNames() method with the getPropertyBytes(String name) or getPropertyString(String name) methods to get specific TXT entries and their values. For instance, if your DESCRIPTION variable is "color=blue" then you can call ServiceInfo.getPropertyString("color") and it will return "blue".