When receiving data using readLine(), even though I put a \"\\n\" at the end of the message using the .flush when sending the message, the while loop that reads my message s
This is because of the condition in the while-loop: while((line = br.readLine()) != null)
you read a line on every iteration and leve the loop if readLine returns null
.
readLine returns only null, if eof is reached (= socked is closed) and returns a String if a '\n' is read.
if you want to exit the loop on readLine, you can omit the whole while-loop und just do:
line = br.readLine()