2

I'm new to Android development and I hope you can help me out.

I use android studio in Linux to develop an UPnP application. On my PC, there are 2 networks, 1 connects to internet by eth0 and another connects to a private network by eth1.

When I launch my application, it can find UPnP servers which locate in network which connect to eth0 but not the one which connect to eth1.

By looking at Setting up Redirection through the Emulator Console, I found a way to redirect network from port 1900 to Android emulator and my application can now find UPnP server in private network.

Android Console: type 'help' for a list of commands
OK
redir add udp:1900:1900
OK
redir add udp:51844:51844
OK
redir add tcp:80:80
KO: can't setup redirection, port probably used by another program on host

The problem is that it's not possible to redirect the protocol tcp from port 80 to streaming video.

My questions are:

1- is there a way to tell android emulator listen on eth1 and not eth0. Or if possible to listen to both eth0 and eth1.

2- if not, how can I redirect port 80 in order to streaming video with my app?

Thanks for your help.

1 Answers1

0

I've got similar problem before. (but that time finally changed to Android to x86 on VM instead.)

For question 1:

1- is there a way to tell android emulator listen on eth1 and not eth0. Or if possible to listen to both eth0 and eth1.

Just some idea, do sudo ip link set eth0 down and then start Android Emulator, I guess emulator should binding to eth1, then start eth0 again. Sorry I'm not working on Linux and could not verify.

2- if not, how can I redirect port 80 in order to streaming video with my app?

It seems 80 port is being used on your linux PC, so figure out which process is using and then stop it tentatively.

Do sudo netstat -nlp | grep 80, and may be nginx or apache I think. After sudo killall YOUR_SERVER, redir add tcp:80:80 may work.

Besides, if eth0 works well, you may not need to bother redir. Just use iptables and set up necessary forwarding from eth0 to eth1 instead. The following link may help: https://help.ubuntu.com/community/IptablesHowTo

yjzhang
  • 4,859
  • 3
  • 19
  • 21