As Sok is buffer based, you need to use buffers to perform I/O operations. The primitive for that is the MultiplatformBuffer class. This package also contains a basic implementation of a buffer pool for object recycling.
| BufferPool (Common) |
class BufferPoolIn order to avoid garbage collection pressure it is a common practice to pre-allocate objects that are known to be long-living for a later use, Kotlin channels give us a great way to implement a quite straightforward object pool. The pool will allocate all the buffers lazily when needed, this means that the pool will never suspend until reaching the maximum size. |
| JSMultiplatformBuffer (JS) |
class JSMultiplatformBufferJS implementation of the MultiplatformBuffer class |
| JVMMultiplatformBuffer (JVM) |
class JVMMultiplatformBufferJVM implementation of the MultiplatformBuffer class |
| MultiplatformBuffer (Common) |
abstract class MultiplatformBufferA MultiplatformBuffer is the primitive type of Sok, you will use it to receive, send and manipulate data |
| NativeMultiplatformBuffer (Native) |
class NativeMultiplatformBufferNative implementation of the MultiplatformBuffer class |
| allocDirectMultiplatformBuffer (JVM) |
fun allocDirectMultiplatformBuffer(size: Int): <ERROR CLASS>Allocate a new MultiplatformBuffer. The buffer is not zeroed, be careful. |
| allocMultiplatformBuffer | expect fun allocMultiplatformBuffer(size: Int): MultiplatformBufferAllocate a new MultiplatformBuffer. The buffer is not zeroed, be careful. |
| wrapMultiplatformBuffer | expect fun wrapMultiplatformBuffer(array: ByteArray): MultiplatformBufferWrap the array with a MultiplatformBuffer. The data will not be copied and the array will be linked to the MultiplatformBuffer class fun wrapMultiplatformBuffer(array: ByteBuffer): <ERROR CLASS>Make a MultiplatformBuffer that use a given ByteBuffer. |