Quick `ktor tcp` question. For the below code on ...
# ktor
k
Quick
ktor tcp
question. For the below code on a
jvm
environment, when the server abruptly closes, we immediately get a null for
receiveChannel.readUTF8Line()
, but on
iOS
we never get a null and
readUTF8Line()
continues to suspend. Is there a workaround to this? Thanks in advance.
Copy code
val selectorManager = SelectorManager(Dispatchers.IO)
        val socket = aSocket(selectorManager).tcp().connect("127.0.0.1", 9002)

        val receiveChannel = socket.openReadChannel()
        val sendChannel = socket.openWriteChannel(autoFlush = true)

        launch(Dispatchers.IO) {
            while (true) {
                val greeting = receiveChannel.readUTF8Line()
                if (greeting != null) {
                    println(greeting)
                } else {
                    println("Server closed a connection")
                    socket.close()
                    selectorManager.close()
                    exitProcess(0)
                }
            }
        }
a
Can you please file an issue with the listed steps of reproduction?
k
Sure, will do that
Hi @Aleksei Tirman [JB] Is there any update on this issue?
a
Unfortunately, there are no updates at this point.
k
Do you have an ETA on this? I'm currently implementing a TCP Client and Server in the Shared code. Everything works perfectly except just that bit 😄
a
I don't have one. Please note that writing comments on the issue would be better so everyone involved could see them.
✅ 1