I did not know where to keep this, so let me put it here. I am researching into network discovery, is there any API or tool which basically detects\identifies any PC or Phone using Internet, which is next to it or nearby.
If I understand your question right It would most likely be on the same subnet so just scan all the hosts on the subnet. There are plentyof tools for port scanning but I personally prefer nmap.
Doesn't have to be on the same network. You still receive packets from any wireless source regardless if it is destined for you, on a different network or otherwise. That's the security risk you run if you use a wireless network without a password. Your packets aren't encrypted (pc <-> wireless router) so you better pray some intern didn't program the login system and simply sends your password clear as day. I would try wireshark though not sure if it does pick those up.
I have a little python script built with pcapy which can capture packets on a network if you want to try it out. Was just a learning project of mine I did awhile ago so nothing to advanced but could suit your needs.
Otherwise ya libpcap would probably work the best if you are looking to code a tool for it in C++.