How to make two android devices to communicate through TCP

前端 未结 5 912
我在风中等你
我在风中等你 2020-12-14 17:10

We want to establish TCP/IP connection between two android devices. For now we thought that it would be simpler if we make the connection device to device. So there is no se

5条回答
  •  余生分开走
    2020-12-14 17:46

    It is possible but you can experience some problems. First of all you have to know the public address of the host you want to contact, and if your two host are in different NATTED networks you should do it using some server (like you do in SIP telephony). Then you have to hope that the contacted host is behind a 'good' NAT like 'full cone' or similar and not behind a 'bad' NAT like 'symmetric' that not allow incoming connection. The fact you use a TCP connection instead of UDP datagram can help you because of the three-way-handshake. In fact most NAT routers accept incoming TCP connection, but not incoming UDP packets.

提交回复
热议问题