PAHO_C_PUB(1L)
πΈ NAME πΈ
paho_c_pub β send (publish) data to an MQTT server π
okay so real talk, bestie: we are in the PAHO_C_PUB(1L) manual page, and this whole thing is about yeeting messages at an MQTT server. that's it. that's the vibe. let's get into it β¨
π SYNOPSIS π
paho_c_pub [topic] [-t|--topic topic] [-c|--connection connection]
[-h|--host hostname] [-p|--port portnumber] [-i|--clientid clientid]
[-u|--username username] [-P|--password password] [-k|--keepalive
keepalive-timeout] [-V|--MQTT-version 31|311|5]
[-q|--qos 0|1|2] [-r|--retained] [-n|--null-message] [-m|--message
message] [-f|--filename filename] [--delimiter delimiter] [--maxdatalen
maxdatalen]
[--message-expiry expiry-interval] [--user-property name value]
[--quiet] [--verbose] [--trace min|max|error|protocol]
[--will-topic will-topic] [--will-payload will-payload] [--will-retain]
[--will-qos 0|1|2]
[--cafile cafile] [--capath capath] [--cert certfile] [--key keyfile]
[--keypass password] [--ciphers cipher-string] [--insecure]
heads up bestie: a few of the things floating around in that synopsis β-i|--clientid,-u|--username,-P|--password,-k|--keepalive,--delimiter,--maxdatalenand--verboseβ are listed right there in the SYNOPSIS but don't get their own lil write-up in the OPTIONS section below. i'm not gonna make stuff up about them, so just know they exist and they're valid to pass. iykyk π«Ά
π DESCRIPTION π
so paho_c_pub sends data to an MQTT server, and it does it using the Eclipse Paho C client asynchronous library, aka MQTTAsync. iconic name, no notes.
MQTT is a protocol that runs over TCP/IP, and the whole point of it is letting programs chat with each other super easily through a server. messages get published to topics, and then they get delivered to literally anyone who subscribed to those topics. it's giving group chat but for processes. π¬
and the matching subscriber program, paho_c_sub, is the one that receives the MQTT messages. they're a duo. soulmates, even. π«Ά
the default mode of operation is that it reads input from stdin and sends a separate message for each line it reads. but there are options that switch the whole mode up so you can send:
- a one-off message of 0 length β that's
-n - a given string β that's
-m - the contents of a file β that's
-f
pick your fighter. π
β¨ OPTIONS β¨
-t,--topicβ the MQTT topic you're publishing the data to. that's where it goes. that's the destination. π-c,--connectionβ the MQTT URI to connect to. it's a combo of transport prefix, host, port, and β for websockets β topic. to connect using TCP you use thetcpprefix, like:tcp://localhost:1883. an example using SSL/TLS:ssl://localhost:1883. an example for websockets, insecure:ws://localhost:1883/topic, and secure:wss://localhost:80/topic. β¨-h,--hostβ the TCP/IP host name of the MQTT server to connect to. along with the--portoption, this is an older alternative to using--connection. vintage but valid. π-p,--portβ the TCP/IP port number of the MQTT server to connect to. along with the--hostoption, also an older alternative to using--connection. πͺ-q,--qosβ the MQTT QoS on which to publish the message. the alternatives are0,1or2. β-V,--MQTTversionβ the version of the MQTT protocol to use. valid options are31(ormqttv31),311(mqttv311) and5(ormqttv5). and lowkey important: if MQTT version 5 is used, then some additional options become valid, like--message-expiryand--user-property. π₯--quietβ do not print error messages. silence. shhh. π€«--traceβ print library internal trace. valid levels aremin,max,errorandprotocol. for when you need to see everything going on inside. π§-r,--retainedβ publish messages with the MQTT retained flag set. π-n,--null-messageβ publish a 0-length message. a message that is literally nothing. it's giving minimalism. π-m,--messageβ publish a one off message with the payload supplied. π-f,--filenameβ publish a one off message with the contents of the file whose name is given. π--message-expiryβ [MQTT version 5 only] sets the expiry interval property of messages, in seconds. β³--user-propertyβ [MQTT version 5 only] sets a user property of sent messages. it takes a pair of strings,nameandvalue. π·οΈ--will-topicβ sets the MQTT will message topic to publish to. here's the dramatic part: if the application ends without sending an MQTT disconnect, the will message gets published to this topic. it's your final words. π--will-payloadβ only used ifwill-topicis set. sets the MQTT will message to be published. π--will-qosβ only used ifwill-topicis set. sets the MQTT QoS at which the will message is published. the alternatives are0,1or2. β--will-retainβ only used ifwill-topicis set. sets the MQTT retained flag on the will message. π--cafileβ only used with a TLS connection. the name of a file for the OpenSSL trust store. π--capathβ only used with a TLS connection. the name of a directory holding OpenSSL trusted certificates. π--certβ only used with a TLS connection. the name of a file for the TLS keystore containing a client certificate to be presented. π--keyβ only used with a TLS connection. the name of a file containing the client private key. ποΈ--keypassβ only used with a TLS connection. the password for the client private key file, if needed. π€«--ciphersβ only used with a TLS connection. a list of cipher suites that the client will present to the server during the TLS handshake. π€--insecureβ only used with a TLS connection. don't check that the server certificate common name matches the hostname. β οΈ
bestie, watch out: --insecure turns off the check that the server certificate common name matches the hostname. it's literally named insecure. do with that information what you will. π
okay that's the whole page, you ate it, periodt ππ
this lil manual page lives over at http://eclipse.org/paho, and the version we're reading is from 31 July 2018 (v1.3.0). thanks for coming to my ted talk, now go publish something iconic π¦β¨π
π¦ where this page comes from
- debian trixie: paho.mqtt.c-examples 1.3.14-2 Β· EPL-2.0
- ubuntu noble: paho.mqtt.c-examples 1.3.13-1build2 Β· EPL-2.0
- ubuntu questing: paho.mqtt.c-examples 1.3.14-2
- ubuntu resolute: paho.mqtt.c-examples 1.3.15-1 Β· EPL-2.0
- ubuntu stonking: paho.mqtt.c-examples 1.3.16+ds-1build1 Β· EPL-2.0
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms