Is Network Active
If your application is set to start on boot then there is a chance that it will start executing before the network is ready. Add this simple check before you perform any critical network tasks.
if (!Network.isActive()) {
System.out.println("Waiting for network");
while (!Network.isActive()) {
try {
Thread.sleep(1000);
} catch (InterruptedException ex) {
ex.printStackTrace(System.err);
}
}
}
System.out.println("Network Ready");
By Kevin Cloutier | Updated On November 3, 2023 2:26 pm | No Comments | Categories: Embedded Programming, Java Code Samples | Tags: ethernet