0

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.

user2652394
  • 1,686
  • 1
  • 13
  • 15
  • If you're using Bonjour to publish the service, why are you scanning IPs? The whole point of Bonjour is to provide sane service discovery using multicast. – David Schwartz Aug 13 '13 at 04:10
  • Im not familiar with iOS, just apply the Bonjour to act as a server, how can I find the servers if there is no specific ip address? Maybe im missing something, can you show me? – user2652394 Aug 13 '13 at 04:14
  • 1
    Bonjour's purpose is to allow efficient service discovery using multicast. There are lots of SO questions about how to use Bonjour on Android such as [this](http://stackoverflow.com/questions/12282257/apple-bonjour-for-android) one, [this](http://stackoverflow.com/questions/2474143/how-can-i-discover-zeroconf-bonjour-services-on-android-im-having-trouble-wi) one, and [this](http://stackoverflow.com/questions/4656379/bonjour-implementation-on-android) one. There's also [this project](http://jmdns.sourceforge.net/). – David Schwartz Aug 13 '13 at 05:24

0 Answers0