How to get IP adress of other hosts in same wifi n

2019-06-11 06:06发布

问题:

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 ?

Can anybody help me ?

Thanks in advance.

回答1:

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.