Benoit TH
Benoit TH

Reputation: 631

Socket connection from PC to Android emulator

So here's what I'm trying to do: I have an Android app that uses a ServerSocket and I need to connect to this socket from my computer.

I've tried to get my IP address using adb shell ifconfig and I can ping this IP from the emulator's shell but I can't ping it from my computer's terminal.

In other words, how can I use Postman to connect on my emulator's web server?

Upvotes: 0

Views: 1853

Answers (1)

Benoit TH
Benoit TH

Reputation: 631

I've found the solution. It seems that if you want to communicate from your computer to your emulator, the IP address to use is 127.0.0.1 and you need to do some port forwarding using ADB in command line.

For example if you emulator is running a server on port 8080

adb forward tcp:8080 tcp:8080

Then call it with localhost:8080

Upvotes: 3

Related Questions