PAHO_CS_PUB(1L)
π PAHO_CS_PUB π
okay bestie, welcome to the paho_cs_pub page β it lives in section 1L of the manual, and it's literally your group chat for the internet, but make it MQTT. sit down, hydrate, let's go π«Ά
β¨ NAME β¨
paho_cs_pub β send (publish) data to an MQTT server. yes, that's the whole job. iconic behavior honestly π
πΈ SYNOPSIS πΈ
paho_cs_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]
that's a LOT of flags and yes, we're doing every single one of them. no skimming. not on my watch π₯
π¦ DESCRIPTION π¦
paho_cs_pub sends data to an MQTT server, and it does it using the Eclipse Paho C client synchronous library β that's MQTTClient to its friends. so like, MQTT is a protocol that runs over TCP/IP, and its whole thing is letting programs talk to each other super easily through a server. messages get published to topics, and then delivered to literally anyone subscribed to those topics. and the matching subscriber program, paho_cs_sub, is the one that receives those MQTT messages. they're a duo. soulmates, fr fr π«Ά
the default mode of operation? it reads input from stdin and sends a separate message for every single line it reads. but bestie, options exist to switch that mode up entirely β you can send a one-off message instead: a 0-length one (-n), a given string (-m), or the contents of a file (-f). choose your fighter π
π OPTIONS π
-t,--topicβ the MQTT topic you're publishing the data to. that's the destination, the address, the where-it-goes β¨-c,--connectionβ the MQTT URI to connect to, aka a combo of transport prefix, host, port, and for websockets, the topic. want TCP? use the tcp prefix, like:tcp://localhost:1883. SSL/TLS?ssl://localhost:1883. websockets, insecure:ws://localhost:1883/topic, and secure:wss://localhost:80/topic. pick your vibe π-h,--hostβ the TCP/IP host name of the MQTT server you're connecting to. paired up with the--portoption, this is the older alternative to using--connection. retro but valid π-p,--portβ the TCP/IP port number of the MQTT server you're connecting to. along with the--hostoption, it's the older alternative to--connection. same era, same energy π-q,--qosβ the MQTT QoS you're publishing the message on. your choices are0,1or2. three flavors, no in-between π-V,--MQTTversionβ which version of the MQTT protocol to use. valid options are31(ormqttv31),311(mqttv311) and5(ormqttv5). and heads up bestie β if you go with MQTT version 5, some extra options become valid, like--message-expiryand--user-property. glow up unlocked β¨--quietβ do not print error messages. silence. peaceful. serenity π--traceβ print the library internal trace. valid levels aremin,max,errorandprotocol. it's giving "let me see EVERYTHING" π-r,--retainedβ publish messages with the MQTT retained flag set. it sticks around π-n,--null-messageβ publish a 0-length message. nothing. emptiness. still a message tho π-m,--messageβ publish a one off message with the payload supplied. just hand it the string, done π-f,--filenameβ publish a one off message with the contents of the file whose name is given. file to message pipeline, slay πβ¨--message-expiryβ [MQTT version 5 only] sets the expiry interval property of messages, in seconds. it has a shelf life, bestie β³--user-propertyβ [MQTT version 5 only] sets a user property of sent messages. it takes a pair of strings: name and value π·οΈ--will-topicβ sets the MQTT will message topic to publish to. and here's the drama: if the application ends without sending an MQTT disconnect, the will message gets published to this topic. it's your final message from beyond π--will-payloadβ only used if will-topic is set. sets the MQTT will message to be published. the actual words of the will π--will-qosβ only used if will-topic is set. sets the MQTT QoS at which the will message is published. the alternatives are0,1or2π«--will-retainβ only used if will-topic is set. sets the MQTT retained flag on the will message. it lingers π--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. bold choice, bestie, live your truth but know what you're doing β οΈ
ngl there are a few flags chilling in the SYNOPSIS that this page doesn't give their own little paragraph β like-i/--clientid,-u/--username,-P/--password,-k/--keepalive,--delimiter,--maxdatalenand--verbose. they're real, they're up there, iykyk π«Ά
that's the whole page, no cap. every flag, every default, every TLS-only caveat, every MQTT-version-5 exclusive β all present and accounted for π
this little masterpiece comes from http://eclipse.org/paho, dated 31 July 2018 at version (v1.3.0), and it's filed under PAHO_CS_PUB(1L). periodt. 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