I\'m writing a simple client/server network application that sends and receives fixed size messages through a TCP socket.
So far, I\'ve been using the <
I think the correct version of ratchet freak's answer is this :
for (int index = 0; index < toRead && (read = inputStream.read(bytes, index, toRead-index))>0 ; index+= read);
it stops reading if read returns -1