ByteStreamConnection

A byte stream: TCP or TLS (RFC 8323 coap+tcp, coaps+tcp). The reliable messaging layer does the Len/TKL framing on top. One messaging-layer instance per connection, so tokens are scoped to it.

Properties

Link copied to clipboard
abstract override val peerIdentity: PeerIdentity

The peer as authenticated by TLS, or PeerIdentity.None on plain TCP.

Link copied to clipboard
abstract override val remote: Endpoint

The peer. For a connection a Connector opened, the Endpoint it was asked to connect to.

Functions

Link copied to clipboard
abstract suspend override fun close()

Closes the connection; afterwards reading reports its end. Idempotent.

Link copied to clipboard
abstract suspend fun read(into: ByteArray, offset: Int, length: Int): Int

Reads up to length bytes into into at offset. Returns the count, or -1 at end of stream.

Link copied to clipboard
abstract suspend fun write(bytes: ByteArray)

Writes all of bytes; the bytes belong to the connection afterwards.