You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The ktor plugin generates the follow code as a raw sockets sample. It doesn't seem to work. The blocking operation happens without Dispatchers.IO context. The launch block is never started
object Client {
@JvmStatic
fun main(args: Array<String>) {
runBlocking {
val socket = aSocket(selectorManager).tcp().connect("127.0.0.1", port = DefaultPort)
val read = socket.openReadChannel()
val write = socket.openWriteChannel(autoFlush = true)
launch {
while (true) {
val line = read.readUTF8Line()
println("server: $line")
}
}
// No Dispatchers.IO context !!!!
for (line in System.`in`.lines()) {
println("client: $line")
write.writeStringUtf8("$line\n")
}
}
}
private fun InputStream.lines() = Scanner(this).lines()
private fun Scanner.lines() = sequence {
while (hasNext()) {
yield(readLine())
}
}
}
The text was updated successfully, but these errors were encountered:
The ktor plugin generates the follow code as a raw sockets sample. It doesn't seem to work. The blocking operation happens without Dispatchers.IO context. The launch block is never started
The text was updated successfully, but these errors were encountered: