Package io.ktor.util.cio

Types

ByteBufferPool

class ByteBufferPool : DefaultPool<ByteBuffer>

Semaphore

class Semaphore

Asynchronous Semaphore.

Exceptions

ChannelIOException

open class ChannelIOException : IOException

An exception thrown when an IO error occurred during reading or writing to/from the underlying channel. The typical error is “connection reset” and so on.

ChannelReadException

class ChannelReadException : ChannelIOException

An exception that is thrown when an IO error occurred during reading from the request channel. Usually it happens when a remote client closed the connection.

ChannelWriteException

class ChannelWriteException : ChannelIOException

An exception that is thrown when an IO error occurred during writing to the destination channel. Usually it happens when a remote client closed the connection.

Extensions for External Classes

java.io.File

java.io.InputStream

java.nio.file.Path

Properties

KtorDefaultPool

val KtorDefaultPool: ObjectPool<ByteBuffer>

The default ktor byte buffer pool

Functions

bufferedWriter

fun ByteWriteChannel.bufferedWriter(
    charset: Charset = Charsets.UTF_8
): BufferedWriter

Open a buffered writer to the channel

pass

suspend fun ByteReadChannel.pass(
    buffer: ByteBuffer,
    block: (ByteBuffer) -> Unit
): Unit

Read data chunks from ByteReadChannel using buffer

toByteArray

suspend fun ByteReadChannel.toByteArray(
    limit: Int = Int.MAX_VALUE
): ByteArray

Convert ByteReadChannel to ByteArray

use

fun ByteWriteChannel.use(
    block: ByteWriteChannel.() -> Unit
): Unit

Executes block on ByteWriteChannel and close it down correctly whether an exception

write

suspend fun ByteWriteChannel.write(
    string: String,
    charset: Charset = Charsets.UTF_8
): Unit

Write a string in the specified charset

writer

fun ByteWriteChannel.writer(
    charset: Charset = Charsets.UTF_8
): Writer

Open a writer to the channel