Skip to content

Instantly share code, notes, and snippets.

@codedmart
Created March 26, 2015 03:32
Show Gist options
  • Select an option

  • Save codedmart/78ac6ab4f6744073ba83 to your computer and use it in GitHub Desktop.

Select an option

Save codedmart/78ac6ab4f6744073ba83 to your computer and use it in GitHub Desktop.
private def recvAll(accum: Int): Array[Byte] = {
@tailrec def recvAllBuf(response: Array[Byte], acc: Int): Array[Byte] = {
val character = in.read()
val responseArray = response :+ character.toByte
acc match {
case 0 => responseArray
case _ => recvAllBuf(responseArray, acc - 1)
}
}
recvAllBuf(Array[Byte](), accum - 1)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment