Connection

sealed interface Connection(source)

A connection for CoAP over a reliable transport (RFC 8323): a ByteStreamConnection (TCP, TLS) or a MessageConnection (WebSocket). The CoAP endpoint runs one reliable messaging layer per connection, so tokens and signaling state (CSM, Ping, Release, Abort) are scoped to it (RFC 8323 §3.3, §4.3).

Opened by a Connector or accepted by a ConnectionListener; close may be called more than once.

Inheritors

Properties

Link copied to clipboard

The peer as authenticated by TLS, or PeerIdentity.None without TLS.

Link copied to clipboard
abstract 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 fun close()

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