views:

606

answers:

1

hi

String url = "http://127.0.0.1:8080/SampleServlet/TestServlet?"; URL url = new URL(con_url);

run in android emualator. but i got the connectexception 02-20 13:05:08.745: ERROR/Server Connection(230): java.net.ConnectException: /127.0.0.1:8080 - Connection refused

please reply me

Thanks

+2  A: 

127.0.0.1 is a Android emulated device's own loopback interface.

In other words, you connect to android emulated device (not to your computer) by using 127.0.0.1.

To get connection to your machine with web-server use 10.0.2.2 or real machine IP address (if you have direct access from web).

Use command ipconfig(Windows)/ifconfig(Linux) to obtain your IP address.

Also see official docs or this!

Yeti
+1 for pointing to documentation.
uthark
Actually, I suggest to modify link to point to official documentation - http://developer.android.com/guide/developing/tools/emulator.html#emulatornetworking
uthark
Updated with your link!
Yeti