I am having a problem with my code which handles whether or not the client has disconnected this is the run method for each thread.
The code gives me an error, something about the nested catch block not ever happening or something. I didn't understand. Thanks for any help. I just want to be able to tell if a client has disconnected from the server while running in a while true loop.

public void run()
{
  try 
  {
     //code that needs to executed once so its not in loop
     while(true)
     {
       try
       {
          //execute server code for servicing client in loop
 
       }
       catch (IOException e) //if the connection is lost will this exception be thrown
       {
      	System.out.println("A Client Has Disconnected");
	break; //break the while loop
        }
      }
   }
   catch (IOException e) //if the execute once code messes up this exception will be thrown
    {
       System.out.println(e);
    }

}

Do you need the catch IOException in the loop? Doesn't the one outside of the loop take care of the same thing? Maybe that's your problem.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.