blob: 67e867c0aa107b59396c35847a47fbe64e8744d9 [file] [log] [blame]
<?php include '../../_includes/header.php' ?>
<div class="panel panel-default">
<div class="panel-body">
<h1>MQTT C++ Client for Posix and Windows</h1>
<p>This C++ client provides an interface which is intended to mirror the Paho Java API as closely as possible. It requires
the <a href="../c">Paho MQTT C client</a> library.</p>
$features = array(
"mqtt-31" => true,
"mqtt-311" => true,
"mqtt-50" => false,
"lwt" => true,
"tls" => true,
"persistence" => true,
"reconnect" => true,
"buffering" => true,
"websocket" => true,
"tcp" => true,
"async" => true,
"sync" => true,
"ha" => true
include '../../_includes/features_list.php';
<h2 id="source">Source</h2>
<p>Source is available from the <a href="">GitHub repository</a>.
<h2 id="download">Download</h2>
<p>Builds will be able to be downloaded <a href="">here</a>.</p>
<h2 id="build-from-source">Building from source</h2>
<p>The C++ client is built for Linux/Unix/Mac with CMake, and uses g++ or clang++ as the compiler. Because it requires a compliant C++11 compiler, only GCC 4.8.1 or clang 3.6 or later are supported.
See the <a href="">GitHub page</a> for complete build instructions.
<p>For Windows, CMake is used to generate a solution file for Visual Studio. Due to the C++11 requirement, the earliest version that can be used with the library is Visual Studio 2015.
See the <a href="">GitHub page</a> for complete build instructions.
<h2 id="documentation">Documentation</h2>
<p>Reference documentation is <a href="">online</a>.</p>
<h3 id="getting-started">Getting Started</h3>
<p>These C++ clients connect to a broker using a TCP/IP connection using Posix or Windows networking, threading and memory allocation calls. They cannot be used with other networking APIs. For that, look at the Embdedded C/C++ client.</p>
<p>Here is a simple example of publishing with the C++ client synchronous API:<p>
int main(int argc, char* argv[])
const std::string TOPIC { "hello" };
const std::string PAYLOAD1 { "Hello World!" };
const char* PAYLOAD2 = "Hi there!";
// Create a client
mqtt::client cli(ADDRESS, CLIENT_ID);
mqtt::connect_options connOpts;
try {
// Connect to the client
// Publish using a message pointer.
auto msg = mqtt::make_message(TOPIC, PAYLOAD1);
// Now try with itemized publish.
cli.publish(TOPIC, PAYLOAD2, strlen(PAYLOAD2), 0, false);
// Disconnect
catch (const mqtt::exception& exc) {
std::cerr << "Error: " << exc.what() << " ["
<< exc.get_reason_code() << "]" << std::endl;
return 1;
return 0;
<?php include '../../_includes/footer.php' ?>