I have a device with configurable IP address. I communicate with this device with UDP on a fixed port. The device is connected to the PC through a switch. There can be multiple devices connected to the switch. I'm developing a C++ library to control the device.
I've read several discussions about how to find the device(s) in my LAN using broadcast + select() (example). Let's say my PC have IP address 192.168.1.10/24, I broadcast to 192.168.1.255 and wait for all responses to get a list of devices. Didn't test yet, but I'm quite sure I can make it work.
As said, the user can configure the IP address. If the user sets the wrong address, e.g. a typo in the address like 193.168.1.12, the device becomes unreachable from the LAN, and we don't know the IP set (it's a typo, so the user probably missed it).
How can I find the device with unknown IP and subnet? Can I broadcast to 0.0.0.0? Do I need to have my PC subnet mask set to 0.0.0.0 to receive the messages back?
Extra notes: the device is an Ethernet camera. What I want to achieve is something similar to that GigEVision protocol does; there's a function that retrieve a list of connected/reachable devices, even outside of PC subnet. GigEVision camera suppliers typically provide a software that list the reachable cameras (outside PC subnet, too) and allow to change the IP address.