Android: Socket connection from Device to PC Emulator

℡╲_俬逩灬. 提交于 2019-12-11 09:29:54

问题


Note: I'm asking this only because other solutions I've seen to the same or similar problems haven't worked.

Situation: I've written a client-server app, that runs fine if the client and the server are both emulators on the PC. A simple socket connection is established by using Telnet.

Problem: Now I want the client to be a real Android device. A USB wire is used for connection. The "USB Debugging" mode is on.

But, no connectivity takes place between the device and the emulator.

What I've done: I obtain the socket to the server using the following line:

thisSocket = new Socket(InetAddress.getByName("My-PC").getHostAddress(), SERVERPORT);

Any suggestions?

来源:https://stackoverflow.com/questions/22845719/android-socket-connection-from-device-to-pc-emulator

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!