
commonMain.com.ditchoom.data.Writer.kt Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of socket-jvm Show documentation
Show all versions of socket-jvm Show documentation
Simple multiplatform kotlin coroutines based socket.
package com.ditchoom.data
import com.ditchoom.buffer.Charset
import com.ditchoom.buffer.ReadBuffer
import com.ditchoom.buffer.toReadBuffer
import com.ditchoom.socket.SocketClosedException
import kotlin.coroutines.cancellation.CancellationException
import kotlin.time.Duration
import kotlin.time.Duration.Companion.seconds
interface Writer {
@Throws(CancellationException::class, SocketClosedException::class)
suspend fun write(buffer: ReadBuffer, timeout: Duration = 15.seconds): Int
@Throws(CancellationException::class, SocketClosedException::class)
suspend fun writeString(string: String, charset: Charset = Charset.UTF8, timeout: Duration = 15.seconds): Int {
return write(string.toReadBuffer(charset), timeout)
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy