connect

abstract suspend fun connect(peer: Endpoint): Connection(source)

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).

Throws

for an endpoint of a scheme not in schemes.

of the transport's own kind when the connection cannot be opened.