1

How to make my android app to get my php server's IP address?

Example, android app sending broadcast message. Then my server listen that message and send the server's ip address to the android app.

Phone ----> Send broadcast message for requesting IP Address
Server <----- Receive the message
Server -----> Send the IP Address information to phone
Phone <---- Receive the information and save the server's IP Address. Finish

I found JmDNS but, my server is PHP not Java. Or, there is a trick or solution the do that job?

  • Are these on the same subnet? – Brad Aug 28 '12 at 19:05
  • for now yes.. but if I do for multiple subnets is that possible? or I just route the packet? – Muhammad Resna Rizki Pratama Aug 29 '12 at 03:02
  • Is there a reason a simple DNS server doesn't solve this problem for you? It would be much more efficient. If you are on different subnets, broadcasts don't work (except in specific configurations). – Brad Aug 29 '12 at 14:04
  • yes. I know this job will done just by DNS. I just thinking how If the DNS Server is down. So, app will search the server itself by sending broadcast message. Note: this app is for local instance. – Muhammad Resna Rizki Pratama Aug 29 '12 at 14:29
  • 1
    Trying to find something via broadcast will be far less reliable than hitting a DNS server. How often does your DNS server go down? You can have backup DNS servers as well. I would be much more inclined to register your application server with a DNS server. The entire internet relies on this mechanism. I'm sure it is sufficient for your application, local or not. – Brad Aug 29 '12 at 14:55
  • so, zeroconf is not the recommended method. I just wanna make my app like some local game that search the server itself. And then I heard about zeroconf/jmdns on some topics. OK I think I must implement DNS backup in my instance. Thanks for your comments.. – Muhammad Resna Rizki Pratama Aug 30 '12 at 01:40
  • But you said that you don't necessarily know if it will be a local server, right? You said that you needed it to cross networks. – Brad Aug 30 '12 at 02:28
  • yes. cross network but still at same building.. I mean not at public network.. – Muhammad Resna Rizki Pratama Aug 30 '12 at 12:30
  • Computers don't know or care about what building you are in. If you are crossing networks in the same building, it is effectively no different than going around the world on the internet. – Brad Aug 30 '12 at 13:16
  • even just crossing 2or3 networks? I think internet is more than that. OK I decide to close this question. – Muhammad Resna Rizki Pratama Aug 30 '12 at 13:54
  • Of course it is, but the method for routing across networks is the same. Broadcast packets are not typically routed. – Brad Aug 30 '12 at 14:16
  • http://www.garykessler.net/library/tcpip.html – Brad Aug 30 '12 at 14:18

0 Answers0