如何获得在同一WIFI网络在Android中其他主机的IP地址?如何获得、主机、地址、在同一

2023-09-07 11:36:10 作者:表情不多心也不痛◇

我使用从我的Andr​​oid应用程序的wifi打印机打印的任何文件。现在,我能够发送文件到打印机,如果我有printer.But的IP地址,我只是有我的设备的IP地址。所以,我怎么能得到同一wifi网络的其他主机(设备,个人电脑)的IP地址在android系统?

I am using wifi printer from my android application to print any file. Now i am able to send file to printer if i have IP address of printer.But i am having my device's IP address only . SO how can i get IP adress of other hosts(devices,PCs) in same wifi network in android ?

任何人可以帮助我吗?

先谢谢了。

推荐答案

您需要执行扫描通过网络获取网络上的现场知识产权的。这样做,你需要采取一个IP范围和尝试ping IP在一个循环。范围可以从你自己的IP来获得。举例来说,如果你的IP是10.0.0.2那么很可能所有的IP的将在10.0.0.0骗10.0.0.255。如果你要检查你需要问的一系列其他IP的。

You need to implement scanning over the network for obtaining live ip's on your network. For doing this you need to take a ip range and try to ping the ip in a loop. The range can be obtained from your own ip. For instance if your ip is 10.0.0.2 then probably all the ip's will lie in 10.0.0.0 to 10.0.0.255. In case you want to check for other ip's you need to ask for range.