问题
I have a device which is configured in station mode. Device is connected to a smart phone over hotspot provided by smartphone. Device needs to search for a service published by an application on smartphone say _abc._tcp.
I am using the command dns-sd -B _abc._tcp
but no output.
Please guide me what I may be missing.
The application publishes the service. I verified it using Bonjour application on android.
Also please clarify
- Is it possible to discover the services while in station mode.
- While searching for services is it necessary to provide complete service name. If not how we can discover all the services published on the smart phone
- Can firewall settings on device affect for service discovery?
- How can we achieve the same in C++. Any libraries which can help in discovering.
Thanks is advance.
回答1:
Is it possible to discover the services while in station mode.
see station mode
While searching for services is it necessary to provide complete service name.
yes
If not how we can discover all the services published on the smart phone
Service discovery is meant to be used to discover a severice you're looking for like a printer or a webpage. One solution you might use is to find all services and query for each instance of the service. Each instance has a name and an ip which you can compare to the phone's ip. Well this is quite ugly I think.
Can firewall settings on device affect for service discovery?
Yes
How can we achieve the same in C++. Any libraries which can help in discovering.
There are libs in almost every language... search for c++ service discovery in your favourite search engine and you will find plenty (or another so-thread with links to one or more)
回答2:
Codewing has already provided answers.
To add to above answers.
Can firewall settings on device affect for service discovery?
Yes. Also service discovery can happen on multiple interfaces (wlan0, eth0...). These interfaces also affect service discovery. To check on this dns configuration file can be checked. In my case interface wlan was disabled in configuration file so I was unable to discover services.
来源:https://stackoverflow.com/questions/40662608/service-discovery-using-dns-sd