Endpoint

sealed interface Endpoint(source)

The other side of a message.

On datagram transports the CoAP messaging layer matches responses, ACKs and RSTs to requests and deduplicates by endpoint equality, so each variant defines equality the way the RFCs scope messages, and a variant never equals another: a UDP peer, a TCP peer and a WebSocket on the same host and port are three peers. Protocol code must compare endpoints, never host and port, so that DTLS can be added without touching it (see Secure).

The variants are final classes with deliberate equality, not data classes: the fields a variant compares are part of the matching rule, and a field added later (an IPv6 zone, say) must not change it by accident.

Inheritors

Types

Link copied to clipboard
class Opaque(val link: String, val address: String) : Endpoint

A non-IP link such as BLE, or LoRa with SCHC (RFC 8824). address is link specific.

Link copied to clipboard
class Secure(val session: SessionId, val epoch: Int, val via: Endpoint, val identity: PeerIdentity) : Endpoint

A peer reached through a DTLS session.

Link copied to clipboard
class Tcp(host: String, val port: Int, val usesTls: Boolean = false) : Endpoint

The remote side of a TCP or TLS connection (RFC 8323). Messages are scoped to the connection, not to the address, so this only describes the peer; a CoAP endpoint keeps at most one connection per value.

Link copied to clipboard
class Udp(host: String, val port: Int) : Endpoint

A UDP peer or group: an IP address and a port.

Link copied to clipboard
class WebSocket(val uri: String) : Endpoint

The remote side of a WebSocket (RFC 8323 §4). Like Tcp, messages are scoped to the connection.