I have little experience in network programming and I am writing a multi platform system which requires each device to be able to find other devices within the same LAN. I am looking for the right approach to do that, and hope that people here can give a good advise. Here are my design requirements:
I am using C++ and the solution needs to be cross platform, which is at least able to run on iOS, Windows, Android.
The system should be pretty light weight, and work under no special setup or network requirements, if possible.
Here are different approaches I am considering:
Using uPnP protocol, but I am not very familiar with it, and it doesn't seems that there are many examples with code on the subject.
Using the traditional socket approach, creating both Server/Client on each device and send the data packet to every IP in the LAN. And do everything manually afterwards. Correct me if I am wrong, if I send a packet to the broadcast address, does that mean that the system automatically sends my packet to every IP within the subnet?
Using an external server all clients will register to, and then getting information about other(already registered) clients from that server. However, I am not sure with what information each client should connect in order to determine they are in the same LAN.
Let me know if what I am thinking makes any senses. Any advice is greatly appreciated.
When connected over a local network, network discovery enables network devices to connect and communicate between the other devices connected to the same network. This allows system administrators to locate devices with ease.
Network discovery is what allows computers and other devices to be discovered on a network. With network discovery, a system will send out messages over the network looking for devices that are discoverable.
One option you have not listed is ZeroConf's DNS-SD protocol.
It is used heavily by Apple - who market it as Bonjour (née Rendezvous).
There is tight integration into iOS and MacOSX.
Apple also provides a Windows implementation, an SDK and has open sourced the mDNS service.
Android appears to support it out of the box.
There's also robust and mature support for Linux in the form of Avahi, included in most desktop distros.
It seems the only platform where a user would need to install anything is Windows, and even then, it is installed with iTunes (used for music library sharing) and the setup software for any of Apple's wireless access points.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With