TcpTransport

class TcpTransport(configureTls: TLSConfigBuilder.() -> Unit? = null) : MqttTransport

TCP transport for MQTT over raw sockets with optional TLS.

TCP is stream-oriented, so receive must reconstruct MQTT packet boundaries by parsing the fixed header and Variable Byte Integer remaining length from the byte stream, then reading exactly that many payload bytes.

Parameters

configureTls

optional hook applied to ktor's TLSConfigBuilder during the TLS handshake, after the SNI server name is set and before platform trust is configured. Use it to trust a private or self-signed CA for this connection only. Ignored for non-TLS endpoints.

Constructors

Link copied to clipboard
constructor(configureTls: TLSConfigBuilder.() -> Unit? = null)
constructor()

Properties

Link copied to clipboard
open override val isConnected: Boolean

Functions

Link copied to clipboard
open suspend override fun close()
Link copied to clipboard
open suspend override fun connect(endpoint: MqttEndpoint)
Link copied to clipboard
open suspend override fun receive(): ByteArray

Reads one complete MQTT packet from the TCP stream.

Link copied to clipboard
open suspend override fun send(bytes: ByteArray)