Connecting two android devices using wifi

喜你入骨 提交于 2020-01-15 03:42:26

问题


I need to connect two android devices using wifi. One device is a server, which sends certain commands to second device. My question is how can I get IP address of the server from the client device? Using of some external wifi network is possible. Android.net.wifi.p2p is not acceptable for me, because it's only supported since API level 14.

UPDATE: is it possible to scan current wifi network to look for connected devices? F.e., in my case client scans its network, finds server and connects to it.


回答1:


Either you have a fixed IP on the Server or u can implement some kind of Broadcast every n-time, where only your device answers.

Maybe you can send a UDP Packet with some HELLO Request to all IPs in your Subnet and when the Server receives it he responses with an ACK Paket.

If you want to check if a Device is available on the network try to ping it and then try to connect.




回答2:


Try this.

Using this I am able to find DLNA devices on wifi network



来源:https://stackoverflow.com/questions/8445168/connecting-two-android-devices-using-wifi

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