// Go into infinite loop, sending messages, receiving responses and
// processing them...
DataInputStream din = (inStream instanceof DataInputStream ?
(DataInputStream)inStream :
new DataInputStream(inStream));
DataOutputStream dout = (outStream instanceof DataOutputStream ?
(DataOutputStream)outStream :
new DataOutputStream(outStream));
while (true) {
String msg = nextMsg();
if (msg != null) {
String inMsg = "", inToken = "";
try {
dout.writeUTF(msg);
while (inToken.compareTo("END") != 0) {
inToken = din.readUTF();
inMsg = inMsg + " " + inToken;
}
processMsg(inMsg);
}
catch (Exception e) {}
}
}