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 | Updated On November 3, 2023 2:26 pm | No Comments | Categories: , | Tags:


INTEG Process Group, inc. © 2023

Real-Time
Mon - Fri, 8am - 4pm EST
P: 724-933-9350
PureChat
Always Available
Contact Form
sales@integpg.com
support@integpg.com

@integpg
@jniordev
422