|Re: [paho-dev] Simultaneous sub/pub-instances|
as Nick says, a single client instance can act as both publisher and subscriber. Or you can create two separate client instances from the same thread. Either way will work fine. The first is more efficient as only one TCP connection will be used to the server.
This will work with both the sync and async APIs. The async API might have more throughput, but its main purpose is to have no blocking calls, for applications for which timing is critical. The sync API has some blocking calls, which can make your applications simpler.
As for the thread safety of the API, the locking is intended to be at the MQTTAsync.c level. But only one instance of the send and receive threads are supposed to be started, regardless of how many client objects or threads there are in the process. What I suspect might be happening is that more than one instance of these threads is being started. A trace would confirm that for me. However, you don't need multiple threads to achieve your aim.
On 15/08/14 23:13, Daniel Rasmussen wrote:
Back to the top