in my server code:
pw = new PrintWriter(stream);
br = new BufferedReader(new InputStreamReader(
socket.getInputStream(), "UTF-8"));
in my client code
BufferedReader br = new BufferedReader(new InputStreamReader(
clientSocket.getInputStream(), "UTF-8"));
OutputStreamWriter stream = new OutputStreamWriter(clientSocket.getOutputStream(), "UTF-8");
PrintWriter pw = new PrintWriter(stream);
then at first, server use: pw.println("OK"); pw.flush();
client receive OK
After that, server use:
pw.println("TRUE")
pw.flush();
this time, client receive a string that has unknow char
\ufffd\ufffdTRUE
then i keep send msg to client and it will receive some \ufffd before every sentence.
Could anybody help me solve the problem?
I could imagine that the server resends byte order markers (0xFFFE 0xFFFF), which are replaced by the replacement character (0xFFFD) at the client side.
Do you re-create the print writer before each send on the server side?