问题
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