Im currently developing a socket-base system between an android and ios app. iOS acts as server (using Bourjour to publish the service). Android apps act as clients, scan for servers, display a list of servers on list-view and connect to server as user-will. Both run on emulators (real devices eventually). I got a specific port for my system, says 49300 for example. The problem is that, there are too many local ip addresses to scan (192.168.x.x), it would be 255 * 255. I develop a queue task to execute the job. Here is a flow:
scan for subnet with for-loop x = 0 -> 255
scanner >= (QUEUE = 5)
wait();
new thread scan for 192.168.x.y with for-loop y = 0 -> 255
scanner++
Scanning Thread:
scan for 192.168.x.y with for-loop y = 0 -> 255
if 192.168.x.y reachable then
add to list
end for
scanner--;
notify();
But seems like it's too much work for the app to do, the android simulator just shutdown, any helps would be appreciated.