java.net.ConnectException - 连接被拒绝Android模拟器 [英] java.net.ConnectException - Connection Refused Android Emulator

查看:340
本文介绍了java.net.ConnectException - 连接被拒绝Android模拟器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个Android模拟器,我从Eclipse中运行,只是试图连接到我的.NET(C#)写了一个简单的socket服务器。

I have an android emulator I'm running from eclipse and just trying to connect to a simple socket server I wrote in .NET (c#).

服务器在同一台机器上运行的端口4505,我能够远程登录(通过腻子)到服务器,它工作得很好,但是当我尝试使用Android模拟器连接到服务器,我收到了: java.net.ConnectException - 本地主机/ 127.0.0.1:4505 - 连接被拒绝在org.apache.harmony.luni.net误差

The server is running on the same machine on port 4505. I am able to telnet (through PuTTy) to the server and it works just fine, but when I try to connect to the server with the android emulator I get a: java.net.ConnectException - localhost/127.0.0.1:4505 - Connection refused at org.apache.harmony.luni.net error.

我假设这是因为仿真器是不同的子网或什么?如果是这样的话,虽然我想我会得到一个不同的错误,将在UnknownHostException异常catch块被捕获...

I'm assuming this is because the emulator is on a different subnet or something? If that were the case though I would think I would be getting a different error that would be caught in the UnknownHostException catch block...

推荐答案

我得到这个想通了。如果我使用内部IP它工作正常(192.168.1。%)的地址。

I got this figured out. If I use the internal ip it works fine (192.168.1.%) address.

对不起,这里的空间浪费,但也许会被别人能够利用这一点。

Sorry for the wasted space here but maybe someone else will be able to use this.

127.0.0.1是设备(仿真器)本身。

the 127.0.0.1 is for the device (emulator) itself.

这篇关于java.net.ConnectException - 连接被拒绝Android模拟器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆