开发者

Help needed in developing an android client server app based on sockets

I am trying to develop a Android clinet to talk to a server running on a LAN. The client is running on an emulator. However while running the android client i am get开发者_StackOverflowting the Exception connection refused. I have tried to establish the connection by running the server on the host machine (on which the emulator is present). This too failed.

Server : :1235

after little research I added redir add tcp:1234:1234 and instead of giving server actual ip , I gave 10.0.2.2. It worked. But if I replace the same with acutal ip it stopped working. is there anythign else I am missing ??


The tcp redirects only work for connections originating from outside the device going into it - they do not let the device connect to things outside.

Using 10.0.2.2 talks to something running on the host as if it were being done from the host itself - ie, it's like using 127.0.0.1 in something on the host. If that is working and using the host's IP address is not, it may be a problem with a firewall or the setup of the server on the host not accepting incoming connections. Can you contact the server from another machine on your LAN?

Incidentally, while not part of your immediate problem, 10.0.2.2 will only work on an emulator, it won't work with a hardware android device.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜