【问题标题】:UDP port forwarding for android emulator; "adb forward udp:port udp:port" and telnet localhost adb_port not working安卓模拟器的UDP端口转发; “adb forward udp:port udp:port”和 telnet localhost adb_port 不工作
【发布时间】:2013-04-18 06:20:27
【问题描述】:

您好,我正在使用 android 模拟器开发应用程序。我需要在可以从本地网络访问的某个端口 X 上注册一个 UDP 套接字。由于 Android 模拟器是 NAT 的,所以我需要端口转发。 我关注了这篇文章“Reaching a network device by IP and port using the Android emulator”。它表明我需要使用

adb forward tcp:localPort tcp:emulatorPort

但是这个方案不适用于 udp(如果有人知道它的 UDP 版本,请告诉我)。对于 UDP,我找到了另一种解决方案,我需要 telnet 到 adb 端口,如下所示(我的 adb 在端口 5037 上运行)

telnet localhost 5037

并使用 redir 命令重定向 UDP 端口

redir add udp:36963:36963

但是当我远程登录时,它给出了以下错误

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.

我尝试了很多方法来解决这个问题,但没有结果。

我需要知道从外部网络访问模拟器的任何解决方案。

【问题讨论】:

  • Kanwar,你找到解决问题的方法了吗?我对这个答案很感兴趣

标签: android android-emulator adb telnet


【解决方案1】:

第一个模拟器的典型 telnet 端口是 5554。

试试:

telnet localhost 5554

然后您需要进行身份验证,说明会打印在控制台中。它应该类似于从 $HOME/.emulator_console_auth_token 复制值,不带尾随 '%'。

auth <auth_token>
redir add udp:36963:36963

【讨论】:

    【解决方案2】:

    这是错误的

    redir add udp:36963:36963
    

    试试这个:

    redir add udp:portA udp:portB
    

    在大多数情况下,portA 和 portB 会有所不同。适应你的代码

    【讨论】:

    • 问题是我无法远程登录。之后我可以运行这个命令。这就是我问的如何解决这个问题
    • windows shell 在 telnet 上有一些问题。尝试改用 PowerShell 或其他 shell。如果你想要一个图形环境,你可以使用 Putty 远程登录
    • 当我在我的设备上@9​​87654323@ 尝试执行redir add 命令时得到/system/bin/sh: redir: not found。怎样才能克服呢?
    • @CsabaToth 它只能通过 telnet 连接而不是 shell 使用。
    猜你喜欢
    • 2011-10-02
    • 2011-11-28
    • 1970-01-01
    • 1970-01-01
    • 2018-11-05
    • 1970-01-01
    • 2011-05-03
    • 2015-07-25
    • 1970-01-01
    相关资源
    最近更新 更多