Paho Asynchronous MQTT C Client Library
Asynchronous MQTT client library for C (MQTTAsync)

An Asynchronous MQTT client library for C.© Copyright 2009, 2023 IBM Corp., Ian Craggs and others

An MQTT client application connects to MQTT-capable servers. A typical client is responsible for collecting information from a telemetry device and publishing the information to the server. It can also subscribe to topics, receive messages, and use this information to control the telemetry device.

MQTT clients implement the published MQTT v3 protocol. You can write your own API to the MQTT protocol using the programming language and platform of your choice. This can be time-consuming and error-prone.

To simplify writing MQTT client applications, this library encapsulates the MQTT v3 protocol for you. Using this library enables a fully functional MQTT client application to be written in a few lines of code. The information presented here documents the API provided by the Asynchronous MQTT Client library for C.

Using the client
Applications that use the client library typically use a similar structure:

  • Create a client object
  • Set the options to connect to an MQTT server
  • Set up callback functions
  • Connect the client to an MQTT server
  • Subscribe to any topics the client needs to receive
  • Repeat until finished:
    • Publish any messages the client needs to
    • Handle any incoming messages
  • Disconnect the client
  • Free any memory being used by the client

Some simple examples are shown here:

Additional information about important concepts is provided here: