I'm having these lines of code:
final int packetLength = 64 //just some constant
InputStream in = socket.getInputStream();
byte[] packet = new byte[packetLength];
int read = in.read(packet, 0, packetLength)
if(read != packetLength) {
//End of stream=
}
Can I be sure that if the read(byte[], int, int) does not return the same value as the length it should read, the stream has reached the end of stream?
Because the next read() call should return -1 shouldn't it?