while (socket != null) {
try {
//Read data.
String str = is.readUTF();
//Pass it on.
if (str != null) {
server.forwardString(str, this);
}
} catch (EOFException e) { //No more data on this socket...
server.forwardString("SERVER SAYS other applet disconnected",
this);
cleanup();
return;
} catch (NullPointerException e) { //Socket doesn't exist...
server.forwardString("SERVER SAYS no socket to other applet",
this);
cleanup();
return;
} catch (IOException e) { //Read problem..
server.forwardString("SERVER SAYS socket trouble with other applet",
this);
cleanup();
return;
} catch (Exception e) { //Unknown exception. Complain and quit.
System.err.println("Exception on is.readUTF():");
e.printStackTrace();
cleanup();
return;
}
}