All Downloads are FREE. Search and download functionalities are using the official Maven repository.

commonMain.socket.streams.OutputStream.kt Maven / Gradle / Ivy

There is a newer version: 0.4.8
Show newest version
package socket.streams

public interface OutputStream {

    public fun write(b: UByte)

    public fun write(b: UByteArray)

    public fun writeUShort(s: UShort) {
        write((s.toUInt() shr 8).toUByte())
        write((s and 0xFFu).toUByte())
    }

    public fun writeUInt(v: UInt) {
        for (i in 0..3) {
            write(((v shr ((3 - i) * 8)) and 0xFFu).toUByte())
        }
    }

    public fun writeULong(l: ULong) {
        for (i in 0..7) {
            write(((l shr ((7 - i) * 8)) and 0xFFu).toUByte())
        }
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy