Socket

interface Socket : 
    ReadWriteSocket,
    ABoundSocket,
    AConnectedSocket

Represents a connected socket

Inherited Properties

localAddress

abstract val localAddress: SocketAddress

Local socket address. Could throw an exception if no address bound yet.

remoteAddress

abstract val remoteAddress: SocketAddress

Remote socket address. Could throw an exception if the peer is not yet connected or already disconnected.

Extension Properties

isClosed

val ASocket.isClosed: Boolean

Check if the socket is closed

Extension Functions

awaitClosed

suspend fun ASocket.awaitClosed(): Unit

Await until socket close

openReadChannel

fun AReadable.openReadChannel(): ByteReadChannel

Open a read channel, could be done only once

openWriteChannel

fun AWritable.openWriteChannel(
    autoFlush: Boolean = false
): ByteWriteChannel

Open a write channel, could be opened only once

tls

suspend fun Socket.tls(
    coroutineContext: <ERROR CLASS>,
    config: TLSConfig
): Socket

Make Socket connection secure with TLS using TLSConfig.

suspend fun Socket.tls(
    coroutineContext: <ERROR CLASS>,
    trustManager: X509TrustManager? = null,
    randomAlgorithm: String = "NativePRNGNonBlocking",
    cipherSuites: List<CipherSuite> = CIOCipherSuites.SupportedSuites,
    serverName: String? = null
): Socket

Make Socket connection secure with TLS.

suspend fun Socket.tls(
    coroutineContext: <ERROR CLASS>,
    block: TLSConfigBuilder.() -> Unit = {}
): Socket

Make Socket connection secure with TLS configured with block.