How to get server message correctly
- by Leo
Problem
I send the message "12345" from the socket server to the client:
myPrintWriter.println("12345");
After that I read this message on client:
int c;
while ((c = inputStream.read( )) != -1)
{
byte[] buffer2 = new byte[1];
buffer2[0] = (byte) c;
String symbol = new String(buffer2 , "UTF-8");
String symbolCode = Integer.toString((int)buffer2[0]);
Log.v(symbol, symbolCode);
}
Log.v("c == -1", "Disconnected");
What I see in log:
With
out.println("abcrefg");
Why? I think it's line termination symbol. I need to get string "12345" or any other and next strings correctly. Help me please.