DEV Community

Manuele Conti
Manuele Conti

Posted on

ncmqtt - Netcat over MQTT

What is ncmqtt?

ncmqtt is an innovative tool for Linux and MacOS that brings the functionalities of netcat into the realm of the MQTT (Message Queuing Telemetry Transport) protocol. MQTT is a lightweight messaging protocol designed for connections with remote locations where a small code footprint is required or the network bandwidth is limited.

Key Features

  • Simplicity: The tool is designed to be straightforward, making it easy to use for both beginners and experienced users.
  • Versatility: Whether you need to troubleshoot, test, or set up simple MQTT-based communications, ncmqtt has you covered.

Getting Started

To build the ncmqtt project, follow these steps:

Clone the repository:

git clone
cd ncmqtt
Enter fullscreen mode Exit fullscreen mode

Set the Path to Paho MQTT Library:

You can set the path to the Paho MQTT library using the PAHO_MQTT_DIR variable when configuring the project with CMake.
If PAHO_MQTT_DIR is not set, CMake will attempt to find the Paho MQTT library using the find_package command.
Build the Project:

mkdir build
cd build
cmake -DPAHO_MQTT_DIR=/path/to/paho.mqtt.c ..
Enter fullscreen mode Exit fullscreen mode


The ncmqtt command supports various options to configure its behavior:

Usage: ncmqtt [<options>]
 -h : show this help message
 -v : show version
 -T : topic for sharing messages: default = nc_channel_pub
 -l : enable listening to incoming messages
 -S : set server host : default =
 -P : set server port : default = 1883
 -A : set server auth = user,pwd
Enter fullscreen mode Exit fullscreen mode

Send a file
Client A:
./ncmqtt -l > output
Client B:
./ncmqtt < file

That's it!

Top comments (0)