aspose file tools*
The moose likes Android and the fly likes Connect to server on LAN Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Mobile » Android
Bookmark "Connect to server on LAN" Watch "Connect to server on LAN" New topic
Author

Connect to server on LAN

Vishal Trivedi
Ranch Hand

Joined: Sep 05, 2011
Posts: 57
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
Rancher

Joined: Sep 21, 2011
Posts: 2408
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

Joined: Sep 05, 2011
Posts: 57
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
Rancher

Joined: Sep 21, 2011
Posts: 2408
Sorry, I don't understand what you're trying to say.
Vishal Trivedi
Ranch Hand

Joined: Sep 05, 2011
Posts: 57
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
Rancher

Joined: Sep 21, 2011
Posts: 2408
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

Joined: Sep 05, 2011
Posts: 57
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

Joined: Sep 05, 2011
Posts: 57
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

Joined: Sep 05, 2011
Posts: 57
And i thing i figured out was that app was running on Emulator and my app-server was accessed on n/w.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Connect to server on LAN