9

For my Android app, users need to connect to a server that will be hosted somewhere on the same LAN. There can be multiple servers hosted on the same LAN. To make it easy for the user, I was going to scan the current LAN that the Android device is connected to and then list all of the network devices that have the server running on it, rather than having the user input the IP to the computer manually.

I'm fairly new to networking, and after some searching I found out that I would have to use a multi-cast DNS search or UDP broadcast to detect the other devices. I also found a nice library called jmDNS, although I've found very few documentation and sample code on it. Could somebody point me in the right direction for what I'm trying to do to save me wasted time (mostly if I'm on the right track)? I'm assuming that I'll have to modify my server a bit to broadcast it's there? It works completely as intended if I input the IP manually into the configuration page on my app. Also, this only needs to discover Windows computers, not sure if that matters. Thanks in advance.

4
  • Yup, mDNS is the probably the best way to go here. You'll need to install the Bonjour service on the Windows PCs though, as it's not natively supported there. Jul 22, 2011 at 15:41
  • By install, do you mean an actual installer (which could be a problem) or just adding the code to my server to make it support Bonjour?
    – telkins
    Jul 22, 2011 at 16:02
  • I think you could go the "add into your server" route, but it would be more work for you; so far, I've been using this installer from Apple instead: en.wikipedia.org/wiki/… (Mac OS and Linux have native support; I believe this service may be a part of the iTunes install, so the computer may already have this) Jul 22, 2011 at 16:09
  • 1
    Other relevant SO question that helped me with a similar problem: stackoverflow.com/questions/4464207/… Jul 18, 2015 at 17:42

2 Answers 2

7

Well, jmDNS is a complete Java library that you could use for your setup. It can be used to braodcast your services which other clients can search for.

Bounjour service on windows is a bit tricky, although it's definitely possible. The easier way, I would say is to use jmDNS for broadcast and discovery for both your servers and clients.

0
0

You would run the jDMs or other service on your local area network as a background service or a dameon.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.