简体   繁体   English

如何获取局域网中的IP地址列表?

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

My Android Phone is connected to a LAN. 我的Android手机已连接到局域网。

There is a way in Java to get the list of LAN IPs? Java中有一种方法可以获取LAN IP列表?

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. 我想获得此列表,因为我的应用程序必须连接到LAN机器上的SQL Server才能同步某些数据。

Could someone help me? 有人可以帮我吗?

You can try to launch a shell command from your Java application: nmap 192.168.1.* 您可以尝试从Java应用程序启动shell命令:nmap 192.168.1。*

But I haven't tryied! 但是我还没试过!

There isn't, but there are ways to advertise/locate a service without knowing the IP address. 没有,但是有一些方法可以在不知道IP地址的情况下公告/定位服务。 Look for zeroconf (what Apple calls bonjour). 寻找zeroconf(Apple称之为bonjour)。 Microsoft has an alternative, UPNP. 微软有一个替代品,UPNP。

Most apps seem to give up and simply ask the user to type in the IP address. 大多数应用似乎都放弃了,只是要求用户输入IP地址。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM