更新时间:2022-12-28 15:52:13
您正试图两台设备在连接到两个不同子网的TCP连接的。这不可能。你是pretty多问一个问题:我的朋友,为什么能听到我,当他站在我的面前,但是如果他不是在另一个房间为使这项工作的唯一方法是打开大门。但是,你必须实现这个门,这就是所谓的NAT穿越或打孔,真的是一个不同的通信概念(检查Android P2P(直接连接)通过互联网(NAT后面)和安卓?NAT穿越)。
You are trying to connect two devices over TCP connected to two different subnets. That's impossible. You are pretty much asking the question: "Why can my friend hear me when he's standing in front of me, but not if he's in another room?" The only way to make that work is to open the door. But you'd have to implement this "door", which is called NAT traversal or "hole punching" and really is a different communication concept (check Android P2P (direct-connection) over the Internet (behind NAT) and Android: NAT Traversal?).
在年底,有三种解决方案,您的问题:
In the end, there are three solutions to your problem:
编辑:结果这听起来像你正试图连接到运行code以上的Android设备的Web服务器。这将是选项1,不过,Android设备无法通过互联网到达。据我所知,你必须把周围:设备将自身注册服务器上,使服务器可以种其他设备连接到它
It sounds like you have a web server that is trying to connect to an Android device running the code above. That would be option 1, but still, an Android device can't be reached over the Internet. As far as I know, you have to turn that around: The device has to register itself on the server so that the server can kind of "connect" other devices to it.