android 127.0.0.1/localhost connection refused 问题的
2010-06-02 13:52
375 查看
调试中通过android simulator模拟器链接localhost或者127.0.0.1,因为我在电脑上面建立了apache,我的代码大概就是
URL url = new URL(urlString);
URLConnection urlconn = url.openConnection();
但是报错了!!
Exception 1:java.net.ConnectException: localhost/127.0.0.1:8080 -
Connection refused
问题是这样的,android模拟器(simulator)把它自己作为了localhost,也就是说,代码中使用localhost或者 127.0.0.1来访问,都是访问模拟器自己!这是不行的!
你想在模拟器simulator上面访问你的电脑,那么就使用android内置的IP 10.0.2.2 吧, 10.0.2.2 是模拟器设置的特定ip,是你的电脑的别名alias
,在模拟器上用10.0.2.2访问你的电脑本机
from:http://80x86.javaeye.com/blog/539356
URL url = new URL(urlString);
URLConnection urlconn = url.openConnection();
但是报错了!!
Exception 1:java.net.ConnectException: localhost/127.0.0.1:8080 -
Connection refused
问题是这样的,android模拟器(simulator)把它自己作为了localhost,也就是说,代码中使用localhost或者 127.0.0.1来访问,都是访问模拟器自己!这是不行的!
你想在模拟器simulator上面访问你的电脑,那么就使用android内置的IP 10.0.2.2 吧, 10.0.2.2 是模拟器设置的特定ip,是你的电脑的别名alias
,在模拟器上用10.0.2.2访问你的电脑本机
from:http://80x86.javaeye.com/blog/539356
相关文章推荐
- android 127.0.0.1/localhost connection refused 问题
- [转]android 127.0.0.1/localhost connection refused 问题
- [转]android 127.0.0.1/localhost connection refused 问题
- Ubuntu 安装配置SSH(ssh: connect to host localhost port 22: Connection refused问题的解决)
- jboss客户端调用ejb“Connection refused to host: 127.0.0.1”问题的解决
- android java.net.ConnectException: Connection 127.0.0.1:8080 refused
- ssh: connect to host localhost port 22: Connection refused 问题
- android java.net.ConnectException: Connection 127.0.0.1:8080 refused
- android java.net.ConnectException: Connection 127.0.0.1:8080 refused
- 在Ubuntu中配置SSH(解决connect to host localhost port 22: Connection refused问题)
- android java.net.ConnectException: Connection localhost:8080 refused
- 在ubuntu中配置SSH(解决connect to host localhost port 22: Connection refused问题)
- ssh: connect to host localhost port 22: Connection refused 问题
- 在ubuntu中配置SSH(解决connect to host localhost port 22: Connection refused问题)
- android 出现org.apache.http.conn.HttpHostConnectException: Connection to http://127.0.0.1 refused的解决方案
- [Android开发常见问题-18] Connection to https://dl-ssl.google.com refused
- Android问题】解决 Android SDK下载和更新失败“Connection to https://dl-ssl.google.com refused...
- 解决connect to host localhost port 22: Connection refused问题
- 防火墙安装ssh: connect to host localhost port 22: Connection refused 问题
- ssh: connect to host localhost port 22: Connection refused 问题