Developers Tip #7: Android Emulator Networking

As a developer, I sometimes run into dead ends in doing simple things. One such situation was trying to get two emulators to directly communicate with each other. Following my rule for helping others where I once failed, I’m going to share some of the tips I’ve found for Emulator Networking in Android.

  1. If you need a port to listen to choose one higher than 1024. Android is based on Linux. If you are going to use a port less than 1024 you need root access which wont happen.
  2. To actually send information to the correct port you will need to setup port forwarding.

Setting up Port Forwarding

  • Start two emulators with the program (usually the first two are going to be Coded 5554 and 556)
  • Add the receiving emulator as a contact in the sending emulator
  • Open a terminal window
  • Type in telnet localhost 5556 (instead of 5556 use the code of the emulator that will receive the message)
  • Type in redir add tcp:port_from:port_to