w3hello.com logo
Home PHP C# C++ Android Java Javascript Python IOS SQL HTML videos Categories
How to make client socket wait for server socket
boolean scanning=true;
while(scanning)
{
    try
    {
        socketChannel.open(hostname, port);
        scanning=false;
    }
    catch(ConnectionException e)
    {
        System.out.println("Connect failed, waiting and trying again");
        try
        {
            Thread.sleep(2000);//2 seconds
        }
        catch(InterruptedException ie){
            ie.printStackTrace();
        }
    } 
}

This is the code for sonics comment





© Copyright 2018 w3hello.com Publishing Limited. All rights reserved.