A Flow wrapper around the Android NsdManager api. If you are using RxJava I would recommend to check out Android Network Service Discovery Rx
The NsdManagerFlow can be created with a context instance.
NsdManagerFlow(context)
The service name used is defined in rfc6763 and finds all services without filtering. ietf.org/rfc/rfc6763.txt
NsdManagerFlow(context)
.discoverServices(DiscoveryConfiguration("_services._dns-sd._udp"))
.flowOn(Dispatchers.IO) // discovering must be done on a different CoroutineContext than main
.collect { event: DiscoveryEvent -> Log.d("Discovery", "${event.service.serviceName}") }
NsdManagerFlow(context)
.registerService(RegistrationConfiguration(port = 12345))
.flowOn(Dispatchers.IO)
.collect { event: RegistrationEvent -> Log.d("Registration", "Registered ${event.nsdServiceInfo.serviceName}") }
NsdManagerFlow(context)
.resolveService(serviceInfo)
.flowOn(Dispatchers.IO)
.collect { event: ResolveEvent -> Log.d("Resolve", "Resolved ${event.nsdServiceInfo.serviceName}") }
The demo app provides a quick way to run the NSD service against your connected network.