0
votes

I have an App with an WebServer running on port 8088. This is implemented with NanoHttpD and it is starting fine.

androidWebServer = new AndroidWebServer(8088);

No I would like send an request from my host machine to this web server which is running in the Android emulator. If I run ifconfig through ADB then this is the output:

adb shell
generic_x86:/ $ ifconfig

radio0 Link encap:UNSPEC
inet addr:192.168.200.2 Bcast:192.168.200.255 Mask:255.255.255.0 inet6 addr: fe80::a0e6:e3ff:fe3e:bfc6/64 Scope: Link inet6 addr: fec0::ad8a:ffcf:643a:9bc3/64 Scope: Site inet6 addr: fec0::f00e:f790:26ba:14ee/64 Scope: Site inet6 addr: fec0::2dd2:d682:2e32:e385/64 Scope: Site inet6 addr: fec0::a0e6:e3ff:fe3e:bfc6/64 Scope: Site inet6 addr: fec0::51d9:32f3:64f2:4055/64 Scope: Site inet6 addr: fec0::e40d:ab32:7b51:4804/64 Scope: Site inet6 addr: fec0::d4be:277c:9cab:49e9/64 Scope: Site inet6 addr: fec0::5dc5:d891:baef:45b9/64 Scope: Site UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1 RX packets:3927 errors:0 dropped:0 overruns:0 frame:0 TX packets:6096 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:1000 RX bytes:2037650 TX bytes:487810

lo Link encap:UNSPEC
inet addr:127.0.0.1 Mask:255.0.0.0 inet6 addr: ::1/128 Scope: Host UP LOOPBACK RUNNING MTU:65536 Metric:1 RX packets:65 errors:0 dropped:0 overruns:0 frame:0 TX packets:65 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:0 RX bytes:4589 TX bytes:4589

wlan0 Link encap:UNSPEC Driver mac80211_hwsim inet addr:192.168.232.2 Bcast:192.168.239.255 Mask:255.255.248.0 inet6 addr: fec0::2190:1727:4d45:d764/64 Scope: Site inet6 addr: fec0::d0b3:8c23:e782:d034/64 Scope: Site inet6 addr: fec0::1cab:3d81:37b5:db4f/64 Scope: Site inet6 addr: fec0::4154:456f:2a3a:38b4/64 Scope: Site inet6 addr: fec0::b812:1e47:3ff:2268/64 Scope: Site inet6 addr: fe80::ff:fe44:5566/64 Scope: Link inet6 addr: fec0::5938:5221:a7da:ba87/64 Scope: Site inet6 addr: fec0::ff:fe44:5566/64 Scope: Site UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1 RX packets:104870 errors:0 dropped:0 overruns:0 frame:0 TX packets:88179 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:1000 RX bytes:108191830 TX bytes:13429466

So it seems the emulator has the IP 192.168.232.2. If I try a ping from my host it doesn't work. No Ping response.

I heard about adb forward port port, but I am not sure what I have to forward or reverse so I can access this Webserver just with the browser like: 192.168.232.2:8088 from my host system.

Any ideas?

1

1 Answers

0
votes

it works with the command

adb forward tcp:8088 tcp:8088

Then it is possible to call localhost:8088 in the hosts browser, and it will redirect to the WebService App in the emulator.