1

I'm developping an app and I need to store the result of the game in my database. I'm gonna do a local server for that. I already saw how to send a request with android. I just want to know how to do it locally. I dont know anything in network so I would like to know if it's different from doing to a non-local server. I want to know if doing localhost:8080/mypage?params is gonna be all right or if I need to be on the same wifi spot to do it, or if I need to do something specific.

Thanks

king
  • 507
  • 1
  • 4
  • 17

1 Answers1

2

As comment said,

Doing localhost on any device will go to itself

You need to use the server real IP. Probably, you have dynamic IP, that means your IP is going to change every time you reset your router, so you need to use a Dynamic DNS service, for example: http://www.dnsexit.com/

Moreover, you're going to need to open corresponding port in your router if the app is going to run out of your LAN.

As comment said:

that is networking 101

cherif
  • 1,164
  • 1
  • 11
  • 16
  • 1
    Thanks for taking my answer :P Also, DNS isn't needed for a local network. A static IP is preffered – OneCricketeer Feb 13 '16 at 18:17
  • ok thank you. It's just for a test so I'm gonna put my ip directly but I'm gonna check your link anyway ;). Thanks – king Feb 13 '16 at 18:19
  • It may be networking 101, but there are subtle differences between 127.0.0.1 and localhost. And there's a performance benefit to 127.0.0.1 -- http://stackoverflow.com/questions/7382602/what-is-the-difference-between-127-0-0-1-and-localhost – Baronz Feb 13 '16 at 18:31
  • 'You need to use your real IP'. Pretty unclear as both Android device and PC have a real ip. – greenapps Feb 13 '16 at 18:35
  • 'Moreover, you're going to need to open corresponding port in your router.' That is nonsense. In his LAN he does not have to do that. – greenapps Feb 13 '16 at 18:37
  • 'Thanks for taking my answer.'. Yes indeed. Strange things happen. – greenapps Feb 13 '16 at 18:42
  • I did `url = "http://ip_address:port"` but I have a timeout error message. Any idea where it could come from ? – king Feb 13 '16 at 19:20