In the following portion of code I make sure that, when the server returns an error message, the client shows it on the screen and, consequently, does not perform the operations within the if.
The problem takes place when the server returns "Value not found". The client doesn't seem to recognize the returned string and remains in an infinite wait.
I've already tried the .contains
and .matches
functions, but they don't work. Only comparing the length of the received string leads to the desired result.
ReceivedName = sIN.readLine();
System.out.println(ReceivedName);
if (ReceivedName.length() > 3) { //ReceivedName = "N/D"; doesn't work.
ReceivedSurname = sIN.readLine();
System.out.println(ReceivedSurname);
} else
continue;
The server performs these operations instead:
if (!found) {
NameToSend = "N/D";
sOUT.println(NameToSend);
sOUT.flush();
continue;
}