I've just started working with Multicast DNS using the NSDManager class for Android. I came upon the NsdChat example from this link https://android.googlesource.com/platform/development/+/master/samples/training/NsdChat/src/com/example/android/nsdchat/NsdHelper.java. In this snipet of code, it seems like registering a service is rather simple but I want to understand the underlying working mechanism of it and I can't find the information anywhere.
public void registerService(int port) {
tearDown(); // Cancel any previous registration request
initializeRegistrationListener();
NsdServiceInfo serviceInfo = new NsdServiceInfo();
serviceInfo.setPort(port);
serviceInfo.setServiceName(mServiceName);
serviceInfo.setServiceType(SERVICE_TYPE);
mNsdManager.registerService(
serviceInfo, NsdManager.PROTOCOL_DNS_SD, mRegistrationListener);
}
If anyone has experience with this and can explain it to me, it's greatly appreciated. These are the main questions I can think of right now.
1) When registerService() is called, with whom is the app registering this service?
2) What is the process of registration? Does the information such as name and port get stored somewhere in a lookup table just like DNS?
3) If anyone has a diagram explaining how the this works, it would be awesome.
Thank you in advance.