Peer-to-Peer Communication HolePunching (Android)

淺唱寂寞╮ 提交于 2019-12-13 19:50:42

问题


I am working on an app that uses peer-to-peer communication between Android devices. It receives and delivers JSON data and the data never goes through the server ever. The server is only used to keep track of user IDs, login times, IP changes, and other stuff. This app will use sockets for communication.

Requirements

  1. JSON data goes directly to an Android device from another Android device without going through server.
  2. The android devices can be connected to any kind network like 3G or Wi-Fi (here I assume I have to use NAT).
  3. Server is used to keep track of IP changes of the Android devices as they may be connected to any kind of network.

Challenges

The main problems I am facing are:

  • I don't know how to connect two devices if they are behind a Wi-Fi network.
  • What approach I can use if I am going to use P2P for delivering JSON data.

Update

For this I have to use hole punching. The idea I got is that no one can connect to a device from the outside. It must start communication from inside the device. So if A request server S for address of B, then server gives the address of B to A and vice versa. Now what? What occurs next?

Any suggestion would be greatly appreciated.

来源:https://stackoverflow.com/questions/35908121/peer-to-peer-communication-holepunching-android

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!