Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Connect to server on LAN

 
Vishal Trivedi
Ranch Hand
Posts: 57
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello

I have an application that connects to server for basic verification and fetching data.Web Service is in Java.
The problem is that i am not able to connect to the web service through Emulator as well as device via USB or Wifi.I tried via both application and browser.

Is it possible to do so in Android or else I will have to use live IP.

And yes Its accessible via browser on LAN.

Thanks and Regards,
Vishal Trivedi
 
Tim Moores
Bartender
Posts: 2730
36
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The emulator can connect to the machine it's running on, but not the network that machine is on. It would use a special IP address for that.

A device can connect to the machine it's connected to via USB, but not the network that machine is on. It would use a special IP address for that.

A device should have no problem to connect to a network through WIFI, though.
 
Vishal Trivedi
Ranch Hand
Posts: 57
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Tim

I last thing i guess the ip address on n.w doesn't has to be special.
Can get it from ipconfig....

 
Tim Moores
Bartender
Posts: 2730
36
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Sorry, I don't understand what you're trying to say.
 
Vishal Trivedi
Ranch Hand
Posts: 57
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I mean to say like 10.0.2.2 is used instead of 127.0.0.1

Am i supposed to use other Ip (apart from what i get on "ipconfig")


Thanks
 
Tim Moores
Bartender
Posts: 2730
36
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Exactly, you'd use 10.0.2.2 and 10.0.1.2 (I think) for the first two scenarios I mentioned. For the 3rd scenario you'd use whatever IP address the target server has.
 
Vishal Trivedi
Ranch Hand
Posts: 57
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks you it worked....

Now i have a new problem....

When I send data to server the server receives a null string....
Logs on my side are correct...
Its just a simple servlet that mirrors back my string



I dont seem to get it.....
 
Vishal Trivedi
Ranch Hand
Posts: 57
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I found out it was the name of the parameter that I had enetered was diff for request.getParameter() and new BasicNameValuePair("json", mJSON)

Thanks
 
Vishal Trivedi
Ranch Hand
Posts: 57
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
And i thing i figured out was that app was running on Emulator and my app-server was accessed on n/w.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic