无法“ping”使用 adb 或 android studio 从 android 进行本地网络

发布于 2025-01-17 02:52:27 字数 1029 浏览 2 评论 0原文

我正在尝试在我的应用程序中建立 tcp 连接,并在具有本地 IP 的 VM 主机上测试它。 在主机上,我打开一个 TCP 端口 4444。

为了测试为什么无法建立连接,我决定首先尝试一个简单的“ping”。 在主机上我这样做”

C:\WINDOWS\system32>ping -c 1 192.168.1.66

Pinging 192.168.1.66 with 32 bytes of data:
Reply from 192.168.1.66: bytes=32 time<1ms TTL=64
Reply from 192.168.1.66: bytes=32 time<1ms TTL=64
Reply from 192.168.1.66: bytes=32 time<1ms TTL=64
Reply from 192.168.1.66: bytes=32 time<1ms TTL=64

Ping statistics for 192.168.1.66:
    Packets: Sent = 4, Received = 4, Lost = 0 (0% loss),
Approximate round trip times in milli-seconds:
    Minimum = 0ms, Maximum = 0ms, Average = 0ms

一切都很好,但是使用 adb:

C:\Users\XXX>adb shell "/system/bin/ping -c 1 192.168.1.66"
PING 192.168.1.66 (192.168.1.66) 56(84) bytes of data.
From 10.0.2.2: icmp_seq=1 Destination Port Unreachable

--- 192.168.1.66 ping statistics ---
1 packets transmitted, 0 received, +1 errors, 100% packet loss, time 0ms

为什么无法从 Android 设备访问目的地以及如何解决此问题? 我尝试关闭 AV,结果相同。

I am tryin to establish tcp connection in my app and test it on VM host with local IP.
On the host I open a tcp port 4444.

To test why the connection cannot be established I decided to first try a simple 'ping'.
On the Host I do"

C:\WINDOWS\system32>ping -c 1 192.168.1.66

Pinging 192.168.1.66 with 32 bytes of data:
Reply from 192.168.1.66: bytes=32 time<1ms TTL=64
Reply from 192.168.1.66: bytes=32 time<1ms TTL=64
Reply from 192.168.1.66: bytes=32 time<1ms TTL=64
Reply from 192.168.1.66: bytes=32 time<1ms TTL=64

Ping statistics for 192.168.1.66:
    Packets: Sent = 4, Received = 4, Lost = 0 (0% loss),
Approximate round trip times in milli-seconds:
    Minimum = 0ms, Maximum = 0ms, Average = 0ms

All is well, however with adb:

C:\Users\XXX>adb shell "/system/bin/ping -c 1 192.168.1.66"
PING 192.168.1.66 (192.168.1.66) 56(84) bytes of data.
From 10.0.2.2: icmp_seq=1 Destination Port Unreachable

--- 192.168.1.66 ping statistics ---
1 packets transmitted, 0 received, +1 errors, 100% packet loss, time 0ms

Why is the destination not reachable from the android device and how to fix this?
I tried with my AV off and the result the same.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文