Most of the help available for this is going to involve telling you why what you're trying to do is a bad idea. 😟
Here are some parts of the problem:
1. The access point knows what devices are connected to it. If you have an app that needs to know this, why aren't you using an access point modified to cooperate?
2. If you're trying to implement a peer-to-peer networking app, so that an app running on two devices on the same network can communicate, there are already frameworks set up to do that. You don't need to exhaustively scan the network to do that, either.
3. If you try to scan the local network, paranoid devices and access point implementations are going to see that as a network attack and stop you.
So why are you trying to do things the hard way?