Have a server-socket running in an android application, which I debug using the emulator. Using the emulators console and "redir add tcp:8888:8888" I can make the service available to a program running on my development machine (as localhost:8888).
The redir port is however not available on any other network interface, meaning I can't access it through the host-ip on either the local development machine, or from a secondary machine on the network. Anyone know if its possible to make the emulator bind to all network interfaces, or have some other trick to enable other hosts on the network to connect to the emulator?
Thanks
I found the OP's comment/suggestion of using rinetd to be much easier than iptables.
rinetd can intercept connections on one interface and forward them to a different IP; so, to solve this problem of the emulator not being accessible to computers other than the host machine, you intercept the incoming connections to your host and forward them to 127.0.0.1
Here's how:
First, install rinetd (http://www.boutell.com/rinetd/)
sudo apt-get install rinetd
". The command could be different in other Linux distros...Next, set up a port redirection in the emulator:
telnet localhost 5554
" (or whatever the port for your avd is)redir add <protocol>:<host port>:<emu port>
" (e.g., "redir add tcp:5000:7000
" to forward tcp data sent to port 5000 on the host to port 7000 in the emulator)Configure rinetd:
/etc/rinetd.conf
and add the line "<host ip> <host port> 127.0.0.1 <localhost port>
". So if your host computer's IP address is 123.45.67.89 and you want to use port 5000 and then forward it to 127.0.0.1:5000, "123.45.67.89 5000 127.0.0.1 5000
"I'm not sure if rinetd is launched automatically after you install it.. to run it:
/usr/sbin/rinetd
"To re-initialize rinetd after modifying the config file:
cat /var/run/rinetd.pid
" shows you the pid of rinetdsudo kill -1 <pid>
" re-initializes it (e.g, "sudo kill -1 3225
")If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With