For an application, I need to get a list of IPs that are connected to the wifi router.
How can we implement this using Java language
to get the list.
For an application, I need to get a list of IPs that are connected to the wifi router.
How can we implement this using Java language
to get the list.
If you need to programmatically recreate the behaviour of netstat
then read and parse the corresponding /proc/net
files.
From /proc/net/protocols
you can find the different type of sockets.
From /proc/net/tcp
(for example) you can find the TCP connections, etc.
Example:
$ cat /proc/net/protocols
protocol size sockets memory press maxhdr slab module cl co di ac io in de sh ss gs se re sp bi br ha uh gp em
[...]
UDP 888 3 2 NI 0 yes kernel y y y n y n y n y y y y y n y y y y n
TCP 1760 6 1 no 304 yes kernel y y y y y y y y y y y y y n y y y y y
[...]
$ cat /proc/net/tcp
sl local_address rem_address st tx_queue rx_queue tr tm->when retrnsmt uid timeout inode
0: 0100007F:1F90 00000000:0000 0A 00000000:00000000 00:00000000 00000000 99 0 9538 1 ffff8800db768000 99 0 0 10 0
1: 0100007F:1F91 00000000:0000 0A 00000000:00000000 00:00000000 00000000 1000 0 10954 1 ffff8800dab78000 99 0 0 10 0
[...]
0100007f
, for example, is hexadecimal for 127.0.0.1.