Connector

interface Connector(source)

Opens connections for CoAP over reliable transports (RFC 8323 §8): coap+tcp and coaps+tcp to an Endpoint.Tcp, coap+ws and coaps+ws to an Endpoint.WebSocket. A CoAP endpoint calls it when a request needs a connection to a peer it has none to, and closes it when the endpoint closes.

Properties

Link copied to clipboard
abstract val schemes: Set<CoapScheme>

The schemes whose endpoints connect accepts. Listing coaps+tcp or coaps+ws is the connector's word that its connections for them run TLS (RFC 8323 §9): a CoAP client sends to such a URI only when a connector or listener of its endpoint serves the scheme.

Functions

Link copied to clipboard
open suspend fun close()

Releases what the connector holds, such as a socket selector. Open connections stay open.

Link copied to clipboard
abstract suspend fun connect(peer: Endpoint): Connection

Opens a connection to peer, whose Connection.remote is peer. A WebSocket connector includes the opening handshake with the subprotocol coap at /.well-known/coap (RFC 8323 §4.1, §8.3); a TLS connector the handshake, offering ALPN CoapScheme.ALPN where its TLS stack can (RFC 8323 §8.2 requires it on every port but 5684).