https://kotlinlang.org logo
#coroutines
Title
# coroutines
a

Alex Gotev

06/14/2020, 4:44 PM
Has somebody used TCP or UDP sockets with Kotlin Coroutines? AFAIK even if you wrap them to be coroutine friendly, they still block the underlying threads and I can't see any advantage over classical Thread Pool Executor.
s

streetsofboston

06/14/2020, 5:56 PM
Yes, they would block. And that is fine. Wrap blocking code in such a thread-pool-executor dispatcher, like Dispatchers.IO.
a

Alex Gotev

06/14/2020, 5:58 PM
Yes, that's what I've done so far. Does it make a substantial difference to use DatagramChannel (java.nio) over DatagramSocket?
84 Views