How to make two android devices to communicate through TCP

前端 未结 5 900
我在风中等你
我在风中等你 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 18:06

    Well to make a TCP socket one device must be listening and the other connecting. However in a real world scenario what you describe is sort of hard. Like if you are going to communicate over a cell network between two phones, I wouldn't be surprised if the network did not allow inbound connections to a phone like that and just sandboxed each phone's IP. So while two phones might be on the same subnet IP range, they might not be on the same physical network which just makes the whole routing problem almost impossible.

    If you are in control of the network and are using Wifi and natting the IPs yourself with both devices within your network, you should be able to do this just like any other client server TCP socket.

提交回复
热议问题