In a RPi console app under Xojo 2022 R3.2 running in Buster in an RPi4 8Gig device the following code results in an exception.
Dim n As NetworkInterface = System.NetworkInterface(0)
I have also tried Dim n As NetworkInterface = System.NetworkInterface(1) too and have limited the connection to Ethernet only, from both Ethernet and WiFi. Also tried in Xojo 2019R1.1
Dim n as NetworkInterface //= System.GetNetworkInterface(0)
Same result. What am I doing wrong???
Edit
Perhaps I am not waiting long enough to run this - it is started by a systemd service. On boot it fails at the spot written above, but if I run the systemd command after boot then it starts fine without errors…
Because After doesn’t “imply a relationship” apparently.
Reading the Unit File docs, I get the impression that After merely means that your service is started after the network-online service starts, but that it may be that it hasn’t actually reached a working state yet. Having code to periodically check to see if the network is available and try again in a few seconds may be the right thing to do anyway. I know we tackled this for Xojo Cloud, but I can’t remember what the solution was unfortunately, but it may have been the support of the watchdog protocol that ultimately fixed it.
That’s what I did - I wrote code to manage this so that it can start anytime I periodically check for a connection, but it is running. This definitely solved the problem. It was something that was not really apparent when I originally wrote this little app a few years ago, using my Windows machine - there was not waiting, as it was always there!