I want to send separate messages using a BufferedOutputStream. So I do bos.write(msg1); bos.flush(); bos.write(msg2); bos.flush()
. On the other end, I have a BufferedReader which relies on separation of these messages:
BufferedReader br = new BufferedReader(new InputStreamReader(server.getInputStream()));
InputStream is = server.getInputStream();
while (true) {
if (br.ready()) {
byte[] bytes = new byte[is.available()];
is.read(bytes);
}
}
But what I get is something like this: "Sending 30 bytes to client; Sending 30 bytes to client" and on the other end: "Received 60 bytes".