TcpServer

interface TcpServer : Closeable

A server that handles TcpSocket is not thread safe and its method must be called from the same coroutine.

Functions

Link copied to clipboard
abstract suspend fun address(): Address

Returns the local address the server is bound to. Only valid after calling listen

Link copied to clipboard
abstract override fun close()

Closes the server. close is idempotent.

Link copied to clipboard
abstract fun listen(block: (socket: TcpSocket) -> Unit)

Starts a background coroutine that calls block on incoming connections. listen can only be called once.