The question comes up now and then. On macOS there is NSPathMonitor from the MBS plugin. Do not use 1.1.1.1 or 8.8.8.8 because those can be blocked. I had a user recently who had to use different DNS servers mandated by his ISP.
I do not have a bug per-se simply because I handle it. What I am asking is when there is no network connection available, what is the best way to handle that? ie, reboot, retry? Close it or something else?
Or is there a Linux command to restart a connection?
The interesting thing is, there are several apps that are running on this machine. 3 or 4 use the network. The others appear to continue to work - although the others do not have any code to do a check periodically.
I think this is up to you and how you want to craft the user experience.
If you think this will be a temporary kind of issue, you could simply let the user know and give them a button to manually retry (while maybe automatically trying based upon a timer). Rebooting could be a possibility here too but how often do you think that’ll be successful versus the negative user experience of a restart? Of course you’d need to code around a perpetual issue where the device would continuously reboot.
Otherwise if this is a more human-less scenario, you might simply want to poll and check for the network until things come online. Of course you might want some way of notifying someone that things aren’t working. I’m not a big Raspberry Pi person myself, but assuming you can put a red LED, play a sound or some other more physical notification if this is a more commonplace issue for you.
I don’t think Xojo is going to have anything low level enough to restart the network interfaces for you. Instead you could probably just do some shell commands to make this happen depending upon the distro you’re using. But in this scenario you’ll want to be very careful and code more defensively than normal so that you don’t end up in a scenario where you make things worse (e.g. turn off a network interface that then fails to ever get turned back on either through your code or some other edge case).
The answer to the thread title is that you just attempt your connection and handle the failure. There are so many variables at play that making a test connection in many cases has no value to you.