use*_*837 9 networking android p2p wifi-direct
我想通过p2p连接连接2个或更多Android设备.据我所知,我可以在一个wifi网络下使用Wi-Fi Direct https://developer.android.com/guide/topics/connectivity/wifip2p.html
但我想连接位于不同地方但可能只有一个IP(vpn或其他)的Android客户端.我怎样才能做到这一点?
这是我的算法
Client_1 register its name and current IP on Server
Client_2 register its name and current IP on Server
Client_1 request registred IP from Server by Client_2 name
Client_2 request registred IP from Server by Client_1 name
Client_1 send message directly to Client_2 IP
Run Code Online (Sandbox Code Playgroud)
如果Client_1和Client_2具有相同的IP,则此算法将不起作用.或者如果客户端在NAT后面.
是否有现成的库以这种方式连接2个或更多Android设备?
小智 1
如果您想出于个人目的进行设置,则可以使用固定 IP SIM 卡。另一种选择是将您的 Android 手机本地私有 IP 转换为公共 IP,这可以通过更新 No-IP应用程序来完成,该应用程序将为您提供一个直接链接来与您拥有的公共 IP 进行通信。
希望我的回答能够对您有所帮助。