read

suspend fun read(length: Int, timeout: Long): ByteArray

Receives the specified number of bytes from the read channel.

Return

Bytes received from the socket. Should be exactly length bytes in length.

Parameters

length

How many bytes we expect to receive from the channel.

timeout

Time in milliseconds after which the read operation should be aborted if it still hasn't completed.

Throws

TimeoutCancellationException

if timeout is reached