Connecting two android devices using wifi

2019-07-19 14:11发布

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.

2条回答
贪生不怕死
2楼-- · 2019-07-19 14:31

Try this.

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

查看更多
地球回转人心会变
3楼-- · 2019-07-19 14:36

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.

查看更多
登录 后发表回答