Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

UDP port forwarding for android emulator; "adb forward udp:port udp:port" and telnet localhost adb_port not working

Hi I am developing an app using android emulator. I need to register a UDP socket at some port X that can be accessible from local network. Since Android emulator is NAT'd so I need port forwarding. I followed this post "Reaching a network device by IP and port using the Android emulator". It shows that I need to use

adb forward tcp:localPort tcp:emulatorPort

but this scheme doesn't work for udp (If anyone knows its version for UDP then please let me know). For UDP I found another solution that I need to telnet to adb port as follows (My adb is running at port 5037)

telnet localhost 5037

and redirect UDP port using redir command

redir add udp:36963:36963

But when I telnet it gives the following error

telnet 127.0.0.1 5037

Connecting to 127.0.0.1:5037...
Connection established.
To escape to local shell, press 'Ctrl+Alt+]'.

Connection closed by foreign host.

I tried a lot to find any solution for this but fruitless.

I need to know any solution for accessing emulator from outer network.

like image 312
Kanwar Saad Avatar asked Apr 24 '13 15:04

Kanwar Saad


People also ask

How do I enable port forwarding on my Android device?

Any call to 127.0.0.1:8085 from your Android test device will be forwarded to the development machine's port 8080. The port forward is active as long as chrome://inspect/#devices tab is open. Note that you might need to launch Chrome on the test device to initially activate the port forwarding.

What is port forwarding in the Android Debug Bridge (ADB)?

The Android Debug Bridge (adb) tool provides port forwarding, an alternate way for you to set up network redirection. For more information, see Forwarding Ports in the adb documentation.

How do I forward a test device port to another port?

The ADB way. You can tell ADB to forward a test device port to a development machine port. adb reverse tcp:8085 tcp:8080. That's it. Any call to 127.0.0.1:8085 from your Android test device will be forwarded to the development machine's port 8080. Just keep your local running server running to reply to the connection request.

How to redirect port 8080 from my Android device?

Any call to 127.0.0.1:8085 from your Android test device will be forwarded to the development machine's port 8080. Just keep your local running server running to reply to the connection request. These redirections are active as long as the device is connected. When you disconnect your device you would need to run these commands again.


1 Answers

The typical telnet port for the first emulator is 5554.

Try:

telnet localhost 5554

Then you'll need to authenticate, the instructions are printed in the console. It should be something like copy the value from $HOME/.emulator_console_auth_token without the trailing '%'.

auth <auth_token>
redir add udp:36963:36963
like image 179
Sean Avatar answered Sep 25 '22 01:09

Sean