how do i stop a tcp ServerSocket from occupyuing a...
# ktor
l
how do i stop a tcp ServerSocket from occupyuing a port? i tried
.close
.awaitClose()
and
.dispose()
but as long as the program is running it's not letting any other programs listen on that port
a
I cannot reproduce it with the following code:
Copy code
suspend fun main() = coroutineScope {
    val selector = ActorSelectorManager(<http://Dispatchers.IO|Dispatchers.IO>)
    val server = aSocket(selector).tcp().bind(InetSocketAddress("127.0.0.1", 2323))

    launch {
        delay(5000)
        server.close()
    }

    while (true) {}
}
After five seconds the command
netstat -tulpn | grep LISTEN | grep 2323
starts returning nothing. Could you please share a code snippet to reproduce your problem?