[SOLVED]How can i find and communicate with android phones in a local network
-
Technically that would be security hole in smartphone OS if you could find phones in local network (be it home, work or public network). As network owner you could find connected devices but that requires some extra software in your router (e.g. OpenWRT based router could expose connected devices) - still you will have extra problem identifying if device is phone or something different.
Basically phone must somehow expose itself and be active here. One option is bluetooth - I'm not sure however if you can hook into bluetooth listener. Usually phones keep bluetooth in hidden mode and you will not find them. One correct solution is NFC: that's what NFC was basically created for. You use it to initiate communication between two devices (by touching them) so they can exchange information using Bluetooth (e.g. Nokia and BB10 successfully can exchange photos using NFC or you can use two NFC enabled phones to initiate gaming using two devices in some games, Angry Birds Magic one example).
Another solution is to have server. Phone could send to server its local IP address. Server will see phone's external address. If external IP address masked using 255.255.255.0 and local address masked 255.255.0.0 matches you can assume that two devices are in the same network. That's not very safe assumption but I guess in 90% cases that would work. After that you can make one phone run server (e.g. using sockets or HTTP library) and other client. While if you have external server I doubt you need another local server.
That's just some ideas but none of them are Qt specific.
-
sorry but i should have been more clear. both the pc and the phone are in the same local network and both have qt apps on it. now i need these two apps to communicate with each other, but the problem is how do i find out the ip address of the other device.
-
mdns/bonjour/rondezvous might also be an option for device discovery. If that is available on android that is.
-
Tobias, good point. Your advice pointed to: http://developer.android.com/training/connect-devices-wirelessly/nsd.html