In my setup I have 2 apps. One running on my local emulator on my macbook. The other on my physical android phone.
In these apps I use ZeroMQ to have a Req/Rep socket, which under the hood uses TCP.
When hosting my server on the emulated device using port 6543, with it's IP at wlan0 I cannot connect to it from my phone. Reversing the roles works fine where the phone hosts the server and emulator connects to it, but in the long run I need emulators to run this server. Eventually iOS developers want to talk to an Android server, so I'd prefer to keep them using emulators for this.
My understanding is that android emulators exist behind a virtual router, so if you want to talk to them you have to use port forwarding.
I've done this for my emulator. Using redir add tcp:7654:6543
. If I understand this correctly then port 7654 of my Macbook should have its traffic redirected to port 6543 of my emulator.
Rather than connect directly to the IP of wlan0
on my emulator, I believe I should be using the IP of my Macbook. For this I run ifconfig | grep "inet "
and connect to the IP address that comes back here.
Trying to receive packets in my app though I still don't see traffic.
Additionally I installed Wireshark and filter on tcp.port == 7654
on the wifi interface of my Macbook. While I do see some messages I'm not sure if what I'm seeing is my message itself, or just the TCP handshake as I see multiple SYN
and [RST, ACK]
but not clear if I should actually be able to see the payloads I'm sending?
I'm not sure at this point what to do. How can I actually verify the traffic is getting to my macbook ok? and how can I verify the forwarding is setup correctly?