B4J Question Get all network IP list

darabon

Active Member
Hi,
I need to get all pc IP that exists in the network,
For the example, There are 4 PC in-network with IP 192.168.1.1,192.168.1.2,192.168.1.3,192.168.1.4
How can I get theirs?
In my app, I need to find a server broker IP with scan IPs and connect to the broker
Thanks
 

Erel

B4X founder
Staff member
Licensed User
Longtime User
 
Upvote 0

Magma

Expert
Licensed User
Longtime User
Hi,
I need to get all pc IP that exists in the network,
For the example, There are 4 PC in-network with IP 192.168.1.1,192.168.1.2,192.168.1.3,192.168.1.4
How can I get theirs?
In my app, I need to find a server broker IP with scan IPs and connect to the broker
Thanks
Hi there...

to find all PCs at network (connected) from windows, there is a command line that you can use, maybe with jshell...
B4X:
arp -a

use jshell (is included by default)
 
Upvote 0

Magma

Expert
Licensed User
Longtime User
...Another thing you can do, for me is better to do that...

is to make an "ip scanner"... you will get first your IP...

for the example let's say your ip is "192.168.168.37", create array for IPsOfLan, and add this as first...

You will keep only the three numbers (or crop until the last full stop) create a loop.. 1 to 254 (x)
Then into loop you are going to "ping" with jshell (-n times of trying, in a local lan is ok to be 1, if you have wifi devices... you can make it longer ...3 or 4)

ping -n 1 192.168.168.x

Note that may be some ips not answer (because of firewall, av)... but the ping will make the job...
now... out of the loop... using jshell... (arp -a or -g is the game)
Will get all the ips exist in your network !!! (search for 192.168.168.x)...add only these ips at your array, with using REGEX split, or anything you want (there are plenty and fast string subs that you can use) also you cna get all mac of their interfaces in other array...
No only the PCs, also wifi, devices, pos... anything connected to your router, including it :)
 
Upvote 0

Magma

Expert
Licensed User
Longtime User
also.. check that.. an IT-Tech utility by me:

 
Upvote 0
Top