readFully

fun readFully(bytes: ByteArray, length: Int = bytes.size)

Fills bytes with exactly length bytes, reading as many times as it takes.

A protocol message has a declared length, so a short read is never an answer - this loops until it has them all or the stream ends.