0

I have a device connected to the local network, acting as a web server, and have mdns built init.

Can I somehow get the IP address of the device using an app built with flutter?

HTTP requests work perfectly fine if I remain connected to the same wifi. But when my phone gets connected to any other wifi some time it does not work.

Arslan
  • 1
  • 4
  • Even if you could get the IP address, you would also need to make sure it can be routed to the server. So there's more to it than just mDNS resolution. – Thomas Nov 16 '22 at 10:46
  • Every app can determine it's local wifi ip requesting it the WifiManager. – blackapps Nov 16 '22 at 10:53
  • It is unclear where a client would run when the server device connects to a different wifi. – blackapps Nov 16 '22 at 10:54
  • mDNS works for most of the times. But some time it does not work. When I do turn off my Phone wifi and turn on it. after that its start to work again. – Arslan Nov 16 '22 at 10:55
  • @blackapps I don't need the IP address of my phone. But I need the IP address of a device(acting as web server) that is connected to same local network. – Arslan Nov 16 '22 at 10:57
  • I am using (https://pub.dev/packages/http) to make the http request. – Arslan Nov 16 '22 at 10:59
  • Please tell on the first line of your post that it is NOT an Android device. You confused me. Dont confuse yet people to come. Also adapt title of post. – blackapps Nov 16 '22 at 11:01
  • `if we have the URL in flutter` I wonder how that url looks like if you have no ip. – blackapps Nov 16 '22 at 11:20
  • `But when my phone gets connected to any other wifi some time it does not work.` I would expect it to never work the if the server is still on the first wifi. – blackapps Nov 16 '22 at 11:27
  • If the phone and device is connected with the same network then it should work. Even if we don't know the ip address of the device. Because I am using the mDNS. The url looks like this "http://mydevice.local/getinfo" – Arslan Nov 16 '22 at 13:30

0 Answers0