Colton Idle
03/01/2024, 6:22 AMreadUtf8Line()
never gets called. Ideas?
val receiveChannel = socket.openReadChannel()
val sendChannel = socket.openWriteChannel(autoFlush = true)
launch(Dispatchers.IO) {
while (true) {
println("awaiting readUtf8Line")
val greeting = receiveChannel.readUTF8Line()
if (greeting != null) {
println(greeting)
} else {
print("got a line that's null?")
}
}
}
If I instead use my terminal to make a socket connection, I can indeed receive messages. Just looks like something is wrong with receiving in kotlin? Maybe it doesn't like readUTF8Line, but I'm kinda confused on how to use readFullyAleksei Tirman [JB]
03/01/2024, 8:15 AMColton Idle
03/04/2024, 3:34 PMColton Idle
03/04/2024, 4:10 PMColton Idle
03/04/2024, 4:11 PMreceiveChannel.read(consumer = { byteBuffer ->
Log.e("FOO", "Got a message of ${Charsets.UTF_8.decode(byteBuffer)}")
})
then that seems to work fine. but
val greeting = receiveChannel.readUTF8Line()
does not. very weird.Aleksei Tirman [JB]
03/04/2024, 5:15 PM\n
)?Colton Idle
03/04/2024, 5:18 PMColton Idle
03/04/2024, 5:18 PMAleksei Tirman [JB]
03/04/2024, 5:19 PMreadUTF8Line
which expects the line break.Colton Idle
03/04/2024, 5:20 PMnc
) then I do not see a /n character.Colton Idle
03/05/2024, 2:48 AM