Posts

Showing posts from July, 2026

WebSocket in Curl

  WebSocket in Curl URL WebSocket Communication URL WebSocket communication with libcurl is achieved by setting up a transfer to a URL using ws:// or wss:// URL schemes. The latter is the secure version, handled over HTTPS. When using wss:// (WebSocket over HTTPS), standard TLS and HTTPS options are acknowledged for the CA and certificate verification. WebSocket communication is done by upgrading a connection from either HTTP or HTTPS. When given a WebSocket URL, libcurl considers it a transfer failure if the upgrade procedure fails. This means that a plain HTTP 200 response code is considered an error for this work. API The WebSocket API is described in the individual man pages for the new API. libcurl can handle WebSocket communication in two ways: Get the WebSocket frames from the server sent to the write callback. You can then respond with curl_ws_send() from within the callback (or outside of it). Set CURLOPT_CONNECT_ONLY to 2L (new for WebSocket). This makes libcurl...

MQTT in Curl

  MQTT in Curl Usage Subscribe: A plain "GET" requests the topic and prints all published messages. Publish: Doing a "POST" publishes the payload data to the topic and exits. TLS Protection Use mqtts:// to perform MQTT over TLS (MQTTS). Subscribing Command Usage: curl mqtt://host/topic Example Subscribe: curl mqtt://host.home/bedroom/temp Note on Subscribing: This sends an MQTT SUBSCRIBE packet for the topic bedroom/temp and listens for incoming PUBLISH packets. Interval Control: You can set the upkeep interval ms option to make curl send MQTT PING requests to the server, preventing the connection from closing due to idleness. Cancellation: You might then need to use the progress callback to cancel the operation. Publishing Command Usage: curl -d payload mqtt://host/topic Example Publish: curl -d 75 mqtt://host.home/bedroom/dimmer Response to a Subscribe Whenever a PUBLISH packet is received, curl outputs two bytes: the topic length (MSB | LSB), follow...

Python Mini Course

Image
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- Python Mini Course ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- Strategic Plan 1. Course Introduction: Why Learn Python and Setting Up Your Environment 2. Quick Task 1: Crafting Personalized Greetings (Input and Output Basics) 3. Quick Task 2: Building a Simple Math Calculator (Variables and Arithmetic Operators) 4. Quick Task 3: Managing Simple Lists of Items (Lists and Basic Iteration) 5. Quick Task 4: Making Decisions with Code (Conditional Statements) 6. Quick Task 5: Analyzing Text with Python (String Methods and Basic Counting) 7. Course Conclusion: Next Steps and Resources for Your Python Journey -------------------------------------------------------------...