android - How to get list of InetAddress in Network Service Discovery? -
hi friends using netwrok service discovery in android app find service type "_dockset._tcp". getting device list unable list of inetaddres of devices. getting inetadress of first discovered device want inetadress of devices discovered. thankful help. using
public void startresolvelistener(){ mresolvelistener= new nsdmanager.resolvelistener() { @override public void onresolvefailed(nsdserviceinfo serviceinfo, int errorcode) { log.d("resolve service failed"," error"+errorcode); } @override public void onserviceresolved(nsdserviceinfo serviceinfo) { ; int port=serviceinfo.getport(); inetaddress host=serviceinfo.gethost(); mhost=string.valueof(host);//here getting 1 host } }; }
i confused how iterate inetaddess
you need follow nsdmanager
diagram , adapt listener to:
mresolvelistener= new nsdmanager.resolvelistener() { @override public void onresolvefailed(nsdserviceinfo serviceinfo, int errorcode) { log.d("resolve service failed"," error"+errorcode); mnsdservicelist.remove(serviceinfo); } @override public void onserviceresolved(nsdserviceinfo serviceinfo) { if(!mnsdservicelist.contains(serviceinfo)){ mnsdservice.add(serviceinfo); mnsdmanager.resolveservice(....); } } };
you need perform operations on service info instances (host, type, etc) individually. of course can modify criteria add list further, filtering service type and/or name.
Comments
Post a Comment