title: What is the best way to link my own hardware with my application on a LAN network?
body: <p>I have hardware based on a microcontroller with Ethernet communication.</p>
  <p>There is a TCP server in the microcontroller.</p>
  <p>To configure the hardware, I have an application made in C# for android.</p>
  <p>The application, in turn, has a TCP client.</p>
  <p>For the app to find my hardware, what I'm doing is pinging each of the addresses of the same network segment of my mobile.
  That is, if the IP address of my mobile is 192.168.0.xx, I ping from the address 192.168.0.1 to the address 192.168.0.255.</p>
  <p>Those addresses that respond, I try to open a socket and send a data frame, if the answer is correct, I assume that I have found a hardware in my local network (there could be more than one connected)</p>
  <p>Obviously those IP addresses that don't respond, or that the socket cannot be opened or that they respond to something wrong are discarded.</p>
  <p>Those valid addresses are displayed in a list for the user to choose with which to interact.</p>
  <p><strong>Also, these valid addresses are saved in the application so that the next time the app is opened, it will automatically connect to the stored addresses, avoiding the scanning of the IP addresses.</strong></p>
  <p>This seems correct to me the first time the user installs the hardware and configures with the app</p>
  <p>The problem is that I was informed that there are users that their routers are configured to renew their IP addresses once a month.</p>
  <p>If this happens, the app should again perform a scan of all the IP addresses again, and this is somewhat cumbersome, since scanning all the IPs takes some time, I don't think users are happy configuring their app and hardware once a month.</p>
  <p><strong>Another cumbersome solution could be to use static IP addresses, but I don't think that's a good idea either.</strong></p>
  <p>Any suggestions on how to improve this?</p>