java.net.ConnectException: /127.0.0.1:8080 an android emulator
String url = "http://127.0.0.1:808开发者_如何学运维0/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
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!
精彩评论