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);
}
}