Welcome toVigges Developer Community-Open, Learning,Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
1.0k views
in Technique[技术] by (71.8m points)

sockets - How to get UDP data from PC to android emulator?

I'm trying to get udp packets into android emulator sent from PC.

Server is sending udp to my PC, port number 4000, and I want to see the udp packet in the android emulator.

So i tried port redirection like:

redir add udp:4000:4000

But i can’t see the packet in the android emulator. What should i change if I want to receive the Udp packet into the android emulator?

question from:https://stackoverflow.com/questions/65918070/how-to-get-udp-data-from-pc-to-android-emulator

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

I found this open bug: https://issuetracker.google.com/issues/80149140 and their suggested workaround works for me!

The easiest way of doing this is to run the emulator with the additional parameters:

-feature -Wifi

So launching my emulator is something like this:

cd "C:Program Files (x86)Androidandroid-sdkemulator"
./emulator.exe -avd tablet_m-dpi_10_1in_-_api_28 -feature -Wifi

And pay close attention that its -Wifi (lowercase f and with a hyphen). You can get a list of your devices by using the command:

./emulator.exe -list-avds

And you still need to do the telnet bit after the emulator is running:

telnet localhost 5554
auth <your+code+here>
redir add udp:8000:8000

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to Vigges Developer Community for programmer and developer-Open, Learning and Share
...