Android resolve.local (mDNS)

I am looking for a solution to resolve .local host names with Android 4.0.4 (without NSD, due to API level 15). On the device, I have no service to detect, just the host name. Could you give an example how to solve the problem? I integrated jmDNS but don’t know how to use to resolve the host name.

mutual CMD:

ping kcmeasurement.local

Pinging kcmeasurement.local [10.202.0.29] with 32 bytes of data:
Reply from 10.202.0.29: bytes=32 time<1ms TTL=64
...

Thank,

Daniel

+4
source share
2 answers

, , jmDNS, NSD. , , , , , .

NSD NSD (, "kcmeasurement" , , "garagedoor" ).

, , . 3-4, Android.

http://www.dodgycoder.net/2015/02/setting-up-bonjourzeroconfmdnsnsd.html

, , jmDNS NSD.

+3

InetAddress IP-. , IP-, , :

try
{
    String hostname = InetAddress.getByName("10.202.0.29").getHostName();
}
catch (UnknownHostException e)
{
    Log.e("MyApplication", "Attempt to resolve host name failed");
}

, , .

jmDNS :

InetAddress localHost = InetAddress.getByName("10.202.0.29");
JmDNS jmdns = JmDNS.create(localHost);
String localHostName = jmdns.getHostName();
-1

Source: https://habr.com/ru/post/1568148/


All Articles