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

Hi, I am developing an application using Android emulator. I need to register a UDP socket on some port X, which can be accessed from the local network. Since the 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. โ€ This shows what I need to use
adb forward tcp:localPort tcp:emulatorPort 

but this scheme does not work for udp (if someone knows their version for UDP, then please let me know). For UDP, I found another solution that I need for telnet for adb port as follows (My adb works in port 5037)

 telnet localhost 5037 

and redirect the UDP port using the 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 a solution for this, but fruitless.

I need to know any solution to access the emulator from an external network.

+7
source share
1 answer

This is not true

 redir add udp:36963:36963 

Try the following:

 redir add udp:portA udp:portB 

In most cases, portA and portB will be different. Adapt your code

0
source

Source: https://habr.com/ru/post/943552/


All Articles