gpt4 book ai didi

android - 有没有一种简单的方法可以设置 android 模拟器来访问主机的 LAN?

转载 作者:塔克拉玛干 更新时间:2023-11-01 21:42:47 24 4
gpt4 key购买 nike

我想从 android 模拟器访问局域网中一台机器提供的网络服务。

如果服务在运行模拟器的同一台机器(称为主机)上运行,我可以添加网络重定向并使用正确的端口访问 10.0.2.2(模拟器中的主机环回接口(interface))。

然而它是在局域网中的另一台机器上运行的。我想我可以在主机上添加另一个重定向到上面的重定向(虽然必须与 iptables 打架......),但是是否存在更简单的解决方案?

最佳答案

好吧,它就是有效 (TM)。

在我测试之前阅读的android模拟器手册中(我在做事之前尝试RTFM)是这样说的:

Each instance of the emulator runs behind a virtual router/firewall service that isolates it from your development machine's network interfaces and settings and from the internet. An emulated device can not see your development machine or other emulator instances on the network. Instead, it sees only that it is connected through Ethernet to a router/firewall.

这让我觉得它无法访问我的局域网。我错了,只需在我的 LAN 上添加服务器的 IP 就可以让我从模拟器访问它。

关于android - 有没有一种简单的方法可以设置 android 模拟器来访问主机的 LAN?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3010130/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com