0

I use android studio (jetbrains) to develop application.

I try to run socket server, this is a part of code:

ServerSocket ss = new ServerSocket(9002);
Socket s = ss.accept();

There are no errors and looks like server running. I use emulator from android-studio, I run it with green button from studio user interface..

But when I scan opened ports in ubuntu terminal - there is no 9002 port. And it is not possible to connect to it outside the emulator...

Firewall is inactive..

How to do that ?

Mikael
  • 1,209
  • 1
  • 16
  • 47

1 Answers1

0

I had to set up port redirect from os level - to emulator.

Firstly need to connect to emulator:

telnet localhost 5554

5554 - is an emulator port, it is printed out in console when you run the emulator.

Then you probably will need to authenticate, this is explained here Android terminal--telnet missing commands, receiving this error : KO: unknown command, try 'help'

Then you set the redirection:

redir add tcp:5000:9002

Official documentation is here https://developer.android.com/studio/run/emulator-networking?hl=it

Mikael
  • 1,209
  • 1
  • 16
  • 47