Communication between two Android emulators

后端 未结 2 1877
暗喜
暗喜 2021-01-22 16:16

My machine is running on window 7. I want to communicate between two android emulator\'s running on same machine.
Emulator first is listening on some IP 10.0.2.15 When seco

相关标签:
2条回答
  • 2021-01-22 16:41

    There may be two reasons

    1. As per my knowledge is concerned you have run is < 2.3 version
    2. Add Internet permission
    3. Try to run the server first say in emulator number 5554 and client (say) 5556
      then type

      telnet localhost 5554
      
    0 讨论(0)
  • 2021-01-22 16:44

    What you need is to install TELNET on your Windows 7 machine. For that, Control Panel -> Programs and Features -> Turn Windows Features On or Off -> Telnet Client (must be ticked).

    Then, in cmd (command prompt), you can say adb devices (if the Android SDK is on your PATH), which returns identifiers such as emulator-5554 and emulator-5556.

    Now with telnet, you can access them with telnet localhost 5554 or telnet localhost 5556.

    To get them to tell you which emulator it is, you can type avd name.

    But more importantly, it tells you this:

    Android Console: Authentication required
    Android Console: type 'auth <auth_token>' to authenticate
    Android Console: you can find your <auth_token> in
    'C:\Users\[youruser]\.emulator_console_auth_token'
    OK
    

    Which is a text file that contains some random cryptic text.

    You can copy paste that into the telnet like so:

    auth cdPi82HewjZg
    

    to which it will say OK, now you can actually run the command the documentation said.

    Now you can say

    redir add tcp:6000:4000
    

    Which means: if the emulator would receive something to Port 6000 from LocalHost, then it should receive it as 4000

    Which means your other emulator can connect to it through the 10.0.2.2 magic loopback IP by sending data to 6000, and it is the other emulator that will receive it, with port 4000.

    It also works not just for tcp: but also for udp:.

    You can list redir and even remove redirections with redir del.

    0 讨论(0)
提交回复
热议问题