How to get the list of IP addresses in a LAN?

2019-08-05 01:18发布

My Android Phone is connected to a LAN.

There is a way in Java to get the list of LAN IPs?

I would like to get this list because my app has to connect to a SQL Server on a LAN Machine to syncronize some datas.

Could someone help me?

2条回答
Evening l夕情丶
2楼-- · 2019-08-05 01:56

There isn't, but there are ways to advertise/locate a service without knowing the IP address. Look for zeroconf (what Apple calls bonjour). Microsoft has an alternative, UPNP.

Most apps seem to give up and simply ask the user to type in the IP address.

查看更多
对你真心纯属浪费
3楼-- · 2019-08-05 02:05

You can try to launch a shell command from your Java application: nmap 192.168.1.*

But I haven't tryied!

查看更多
登录 后发表回答