1async(3) Library Functions Manual async(3)
2
3
4
6 async - Asynchronous vs synchronous client applications This client
7 library supports two modes of operation. These are referred to as
8 synchronous and asynchronous modes. If your application calls
9 MQTTClient_setCallbacks(), this puts the client into asynchronous mode,
10 otherwise it operates in synchronous mode.
11
12 In synchronous mode, the client application runs on a single thread.
13 Messages are published using the MQTTClient_publish() and
14 MQTTClient_publishMessage() functions. To determine that a QoS1 or QoS2
15 (see Quality of service) message has been successfully delivered, the
16 application must call the MQTTClient_waitForCompletion() function. An
17 example showing synchronous publication is shown in Synchronous
18 publication example. Receiving messages in synchronous mode uses the
19 MQTTClient_receive() function. Client applications must call either
20 MQTTClient_receive() or MQTTClient_yield() relatively frequently in
21 order to allow processing of acknowledgements and the MQTT 'pings' that
22 keep the network connection to the server alive.
23
24 In asynchronous mode, the client application runs on several threads.
25 The main program calls functions in the client library to publish and
26 subscribe, just as for the synchronous mode. Processing of handshaking
27 and maintaining the network connection is performed in the background,
28 however. Notifications of status and message reception are provided to
29 the client application using callbacks registered with the library by
30 the call to MQTTClient_setCallbacks() (see MQTTClient_messageArrived(),
31 MQTTClient_connectionLost() and MQTTClient_deliveryComplete()). This
32 API is not thread safe however - it is not possible to call it from
33 multiple threads without synchronization. You can use the MQTTAsync API
34 for that.
35
36
37
38Paho MQTT C Client Library Thu Jul 22 2021 async(3)