Class MqttNetworkChannel
- Namespace
- nanoFramework.M2Mqtt
- Assembly
- nanoFramework.M2Mqtt.dll
Channel to communicate over the network
public class MqttNetworkChannel : IMqttNetworkChannel
- Inheritance
-
MqttNetworkChannel
- Implements
- Inherited Members
- Extension Methods
Constructors
MqttNetworkChannel(Socket)
Constructor
public MqttNetworkChannel(Socket socket)
Parameters
socket
SocketSocket opened with the client
MqttNetworkChannel(Socket, bool, X509Certificate, MqttSslProtocols)
Constructor
public MqttNetworkChannel(Socket socket, bool secure, X509Certificate serverCert, MqttSslProtocols sslProtocol)
Parameters
socket
SocketSocket opened with the client
secure
boolSecure connection (SSL/TLS)
serverCert
X509CertificateServer X509 certificate for secure connection
sslProtocol
MqttSslProtocolsSSL/TLS protocol version
MqttNetworkChannel(string, int)
Constructor
public MqttNetworkChannel(string remoteHostName, int remotePort)
Parameters
MqttNetworkChannel(string, int, bool, X509Certificate, X509Certificate, MqttSslProtocols)
Constructor
public MqttNetworkChannel(string remoteHostName, int remotePort, bool secure, X509Certificate caCert, X509Certificate clientCert, MqttSslProtocols sslProtocol)
Parameters
remoteHostName
stringRemote Host name
remotePort
intRemote port
secure
boolUsing SSL
caCert
X509CertificateCA certificate
clientCert
X509CertificateClient certificate
sslProtocol
MqttSslProtocolsSSL/TLS protocol version
Properties
DataAvailable
Data available on the channel
public bool DataAvailable { get; }
Property Value
RemoteHostName
Remote host name
public string RemoteHostName { get; }
Property Value
RemoteIpAddress
Remote IP address
public IPAddress RemoteIpAddress { get; }
Property Value
RemotePort
Remote port
public int RemotePort { get; }
Property Value
ValidateServerCertificate
True to check the server certificate when connecting using TLS. Disabling this property will bypass the validation of the server root CA certificate. Using the library this way it's unsecured and, therefore, not recommended.
public bool ValidateServerCertificate { get; set; }
Property Value
Methods
Accept()
Accept connection from a remote client
public void Accept()
Close()
Close the network channel
public void Close()
Connect()
Connect to remote server
public void Connect()
Receive(byte[])
Receive data from the network
public int Receive(byte[] buffer)
Parameters
buffer
byte[]Data buffer for receiving data
Returns
- int
Number of bytes received
Receive(byte[], int)
Receive data from the network channel with a specified timeout
public int Receive(byte[] buffer, int timeout)
Parameters
Returns
- int
Number of bytes received
Send(byte[])
Send data on the network channel
public int Send(byte[] buffer)
Parameters
buffer
byte[]Data buffer to send
Returns
- int
Number of byte sent