Hello! Why Socket::close or Socket::dispose are no...
# ktor
p
Hello! Why Socket::close or Socket::dispose are not suspend functions?
a
Could you please explain why do need them as suspendable methods?
p
Close function can do some networking (for example send reset packet or flush unsent bytes), so now this function is possible blocking. While send and receive are suspend. It is not 100% coroutine based communication.
By the way, flush function also not suspend. Why?
a
That’s probably because the
Closeable
interface has blocking
close
method. If you need to send a reset packet you can do it on a higher level.
Since
close
is a low-level operation that should only close a socket.
p
What about flush?