简体   繁体   中英

Fetching IP address of router to which iPhone is connected using Bonjour

I want to fetch the IP address of router to which my iPhone is currently connected via scanning the MDNS.

I think this can be achievable with Bonjour programming provided by Apple but can't get the proper implementation/guidance.

Can somebody help here with some reference code/documentations/url?

Thank you

mDNS and routing are completely unrelated systems; mDNS traffic doesn't even get routed.

The only ways I know of to get routing data are to use either sysctl or a routing socket. And I think only the sysctl works in iOS (because you aren't root), but I'm not certain of that. See:

Getting routing table on MACOSX (programmatically)

And even that will get you only the router's local network address, which may not be what you're looking for, depending on your goals.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM