<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Abdallah rabie on Medium]]></title>
        <description><![CDATA[Stories by Abdallah rabie on Medium]]></description>
        <link>https://medium.com/@abdallahrabie45?source=rss-b976f647e182------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*UEnvSsSSfVWTuSse.jpg</url>
            <title>Stories by Abdallah rabie on Medium</title>
            <link>https://medium.com/@abdallahrabie45?source=rss-b976f647e182------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sat, 28 Nov 2026 05:05:50 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@abdallahrabie45/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[From Segfault to Solution]]></title>
            <link>https://medium.com/@abdallahrabie45/from-segfault-to-solution-27af744b9714?source=rss-b976f647e182------2</link>
            <guid isPermaLink="false">https://medium.com/p/27af744b9714</guid>
            <category><![CDATA[gdb]]></category>
            <category><![CDATA[cpp]]></category>
            <category><![CDATA[crash]]></category>
            <category><![CDATA[segmentation-fault]]></category>
            <category><![CDATA[c-programming]]></category>
            <dc:creator><![CDATA[Abdallah rabie]]></dc:creator>
            <pubDate>Fri, 10 Jul 2026 11:53:36 GMT</pubDate>
            <atom:updated>2026-07-10T11:53:36.804Z</atom:updated>
            <content:encoded><![CDATA[<p>If you’ve ever shipped C or C++ in production, you know the drill: the process dies with Segmentation fault (core dumped), and the real work starts. Where did it crash? What was on the stack? What was in the register that pointed to garbage memory?</p><p>This article walks through the full loop, end to end:</p><ol><li><strong>Write and trigger a real crash</strong> from a small, “infected” C program.</li><li><strong>Capture and extract the crash log</strong> using coredumpctl (systemd&#39;s built-in core dump manager).</li><li><strong>Hand that log to an AI model</strong> and use it to actually root-cause the segfault.</li></ol><p>I built a small tool, <a href="https://github.com/Rabie45/c-crash-analyzer"><strong>c-crash-analyzer</strong></a>, that automates steps 2 and 3 — this article is effectively the manual walkthrough of what it does under the hood, so you understand the mechanics before trusting a tool to do it for you.</p><h3>Part 1 — Reproducing a Crash on Purpose</h3><p>To have something to analyze, we need a program that misbehaves predictably. Here’s a small “infected” C file with a classic bug: a pointer that’s used after it’s been freed.</p><pre><br>// crash_demo.c<br>#include &lt;stdio.h&gt;<br>#include &lt;stdlib.h&gt;<br>#include &lt;string.h&gt;<br><br>typedef struct node {<br>    int value;<br>    struct node *next;<br>} node_t;<br><br>node_t *find_node(node_t *head, int target) {<br>    node_t *cur = head;<br>    while (cur != NULL) {<br>        if (cur-&gt;value == target) {<br>            return cur;<br>        }<br>        cur = cur-&gt;next;<br>    }<br>    return NULL; /* not found */<br>}<br><br>int use_node(node_t *n) {<br>    /* BUG: caller never checks for NULL before this call */<br>    return n-&gt;value * 2;<br>}<br><br>int process_list(node_t *head, int target) {<br>    node_t *found = find_node(head, target);<br>    return use_node(found);<br>}<br><br>int main(void) {<br>    node_t a = { .value = 1, .next = NULL };<br>    node_t b = { .value = 2, .next = NULL };<br>    a.next = &amp;b;<br><br>    printf(&quot;Looking for value 5 in a 2-node list...\n&quot;);<br>    int result = process_list(&amp;a, 5); /* 5 isn&#39;t in the list -&gt; find_node returns NULL */<br>    printf(&quot;Result: %d\n&quot;, result);<br><br>    return 0;<br>}</pre><p>This compiles fine, and it might even <em>appear</em> to run fine a few times — which is exactly what makes use-after-free bugs so dangerous in long-running data-plane or networking code. Eventually the freed memory gets reused by the allocator and the program dereferences garbage.</p><h3>Compile with debug symbols</h3><p>Debug symbols are non-negotiable here. Without -g, your crash log will be a wall of hex addresses with no line numbers.</p><pre>gcc -g -O0 -o crash_demo crash_demo.c</pre><h3>Trigger the crash</h3><pre>./crash_demo<br># Processing record: packet_buffer (id=42)<br># Segmentation fault (core dumped)</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/555/1*h669Pmc4j1tFsGrfU3We6g.png" /></figure><h3>Part 2 — Extracting the Crash Log with coredumpctl</h3><pre>coredumpctl list</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*xm1rez2ZPWTHGS4dky1vTg.png" /></figure><p>You’ll see a table with a timestamp, PID, UID, signal, and the executable — find your crash_demo entry.</p><p><strong>Pull a full crash report</strong></p><pre>coredumpctl info crash_demo</pre><p>This dumps everything: the signal (SIGSEGV), the faulting address, the command line, environment, and — critically — the backtrace at the moment of the crash.</p><h3>Drop straight into GDB with the core loaded</h3><p>This is the most useful command in the whole workflow:</p><pre>coredumpctl gdb crash_demo</pre><p>coredumpctl finds the matching core dump, loads it alongside the original binary (using the debug symbols from -g), and drops you into an interactive GDB session already positioned at the crash. From there:</p><pre>(gdb)bt<br>#0  0x0000585ee1a631dd in use_node (n=0x0) at crash_demo.c:23<br>#1  0x0000585ee1a63217 in process_list (head=0x7ffc5b8e3c00, target=5)<br>    at crash_demo.c:28<br>#2  0x0000585ee1a6327a in main () at crash_demo.c:37</pre><pre>(gdb) print *n<br>Cannot access memory at address 0x0</pre><p>That print *n output is the smoking gun: the struct has been zeroed out, which is a strong signal the memory was freed and reused (or poisoned) before we touched it again — exactly what happened in the source.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*PUkTmM2sFTO81FnLxPfn9g.jpeg" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*56qjQo6xy3o-P_i_EIv9IQ.jpeg" /></figure><h3>Save the report to a file</h3><p>For sharing, archiving, or feeding to another tool (including an AI model), dump it to a plain text file:</p><pre>coredumpctl gdb crash_demo -- -batch -ex &quot;bt full&quot; -ex &quot;info registers&quot; &gt; crash_report.txt</pre><p>That crash_report.txt is now a self-contained artifact: backtrace, register state, and source context.</p><h3>Part 3 — Letting AI Solve the Segfault</h3><p>Manually pasting a backtrace into a chat window works, but it doesn’t scale, and it’s easy to forget a step (symbolizing addresses, actually reading the source at the crash site, checking the failure against known patterns). So I turned that checklist into a <strong>Claude Code skill</strong>: <a href="https://github.com/Rabie45/c-crash-analyzer">c-crash-analyzer</a>.</p><p>It’s not a standalone CLI you run — it’s a skill Claude Code loads automatically. Under the hood it follows a fixed pipeline every time:</p><ol><li><strong>Identify the log format</strong> — GDB backtrace, dmesg/kernel oops, ASAN report, or systemd-coredump/coredumpctl output.</li><li><strong>Symbolize raw addresses to </strong><strong>file:line</strong>, via the bundled scripts/symbolize.sh, which wraps addr2line/gdb.</li><li><strong>Read the actual source</strong> at the crash site — not just the log, the real code.</li><li><strong>Classify the failure</strong> against a pattern catalog in REFERENCE.md: null deref, use-after-free, buffer overflow, stack overflow, dangling pointer, double free.</li><li><strong>Report back</strong>: crash site → call chain → classification → root cause → suggested fix → confidence/gaps.</li></ol><h3>Installing it</h3><p>Project-local (checked into the repo, shared with the team):</p><pre>git clone https://github.com/Rabie45/c-crash-analyzer.git .claude/skills/c-crash-analyzer<br>chmod +x .claude/skills/c-crash-analyzer/scripts/symbolize.sh<br>git add .claude/skills/c-crash-analyzer<br>git commit -m &quot;Add c-crash-analyzer skill&quot;</pre><p>Claude Code loads only the skill’s name + description up front; the full instruction set in SKILL.md (and the linked REFERENCE.md and symbolize.sh) only loads when the skill actually triggers.</p><h3>Running it against our crash</h3><p>No manual prompt-crafting needed — save the coredumpctl gdb output from Part 2 to a file and either let it auto-trigger by pasting the log, or invoke it explicitly:</p><pre>/c-crash-analyzer @crash_report.txt</pre><p>Since we already have crash_demo.c and its debug symbols in the same repo, the skill can symbolize the three frames from our backtrace, open crash_demo.c at line 23, and walk the call chain back through process_list and find_node on its own — the same steps we did by hand in Part 2, just automated and checked against the pattern catalog instead of eyeballed.</p><h3>What the report looks like</h3><p>For this crash, the skill’s pipeline lands on:</p><ul><li><strong>Crash site</strong>: use_node, crash_demo.c:23 — n-&gt;value dereferenced.</li><li><strong>Call chain</strong>: main → process_list(head=&amp;a, target=5) → find_node returns NULL → use_node(NULL).</li><li><strong>Classification</strong>: null pointer dereference (REFERENCE.md catalog entry — distinguished from use-after-free by the Cannot access memory at address 0x0 signature rather than a stale-but-nonzero address).</li><li><strong>Root cause</strong>: find_node legitimately returns NULL on a &quot;not found&quot; result; process_list never checks for it before passing the pointer into use_node.</li><li><strong>Suggested fix</strong>: add a NULL check in process_list before calling use_node, and decide on a defined &quot;not found&quot; return value instead of dereferencing blindly.</li><li><strong>Confidence/gaps</strong>: high confidence — the backtrace, source, and pattern match all agree; no missing symbols or stripped frames in this case.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*bwrLvj_etutvgp8xnSbfIQ.png" /></figure><p>That’s the same conclusion we reached manually in Part 2, but produced from the log and source alone, following a repeatable procedure instead of ad hoc reasoning — which matters once you’re triaging real crash reports instead of a 20-line demo.</p><h3>Why this beats a raw chat prompt</h3><p>A one-off prompt gets you a plausible-sounding answer. A skill gets you the <em>same steps, every time</em>: format detection, symbolization, source lookup, and classification against a fixed pattern catalog, so two different crashes with the same underlying bug type get consistent, comparable reports — useful when you’re triaging a batch of coredumpctl entries after a bad deploy, not just debugging one demo file.</p><h3>Wrapping Up</h3><p>The workflow is simple once it’s automated, but it’s worth doing manually at least once so you trust what the tooling is actually doing:</p><ol><li>Crash a real, debuggable binary (-g, no stripping).</li><li>Extract the full context with coredumpctl gdb — backtrace, registers, and source line, not just the signal name.</li><li>Let c-crash-analyzer symbolize, read the source, and classify the failure against a known pattern catalog instead of re-deriving the root cause from scratch every time.</li></ol><p>If you want to install the skill yourself, the code is here: <a href="https://github.com/Rabie45/c-crash-analyzer"><strong>github.com/Rabie45/c-crash-analyzer</strong></a>.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=27af744b9714" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Why Your Software Will Never Handle 10M Packets/sec]]></title>
            <link>https://medium.com/@abdallahrabie45/why-your-software-will-never-handle-10m-packets-sec-770ed8a2453e?source=rss-b976f647e182------2</link>
            <guid isPermaLink="false">https://medium.com/p/770ed8a2453e</guid>
            <category><![CDATA[low-code]]></category>
            <category><![CDATA[dpdk]]></category>
            <category><![CDATA[c-programming]]></category>
            <category><![CDATA[backend]]></category>
            <category><![CDATA[low-latency]]></category>
            <dc:creator><![CDATA[Abdallah rabie]]></dc:creator>
            <pubDate>Thu, 29 Jan 2026 19:00:23 GMT</pubDate>
            <atom:updated>2026-01-29T19:00:23.268Z</atom:updated>
            <content:encoded><![CDATA[<p>Once you picture a system that can handle 10 million packets per second, it’s tempting to assume it must be some kind of backend “magic” — a clever software architecture, a special stack of frameworks, or maybe an ultra-optimized implementation in C/C++.</p><p>If that’s where your mind goes, you’re thinking like an evil genius.</p><p>But before we talk about why C/C++ can make performance like that possible, let’s first talk about the frameworks people usually reach for.</p><p>When you work with modern backend frameworks, you often try to optimize inside slow architectures.</p><p>When you build a backend, the first question is usually:</p><blockquote><em>“Which framework should I use?”</em></blockquote><p>But at high scale, frameworks hide costs that show up as latency spikes, freezes, or wasted CPU.</p><ul><li>Spring Boot: Garbage collection can introduce “stop-the-world” pauses, where latency suddenly jumps even if your average looks fine.</li><li>Node.js: The event loop can stay responsive — until one blocking call stalls it, and then the whole service appears frozen.</li><li>FastAPI: Under heavy load, CPU-bound work can saturate the process quickly, and Python’s concurrency model won’t save you from that.</li></ul><p>So when you build on these (or similar stacks), you often end up trying to optimize <em>inside</em> a slow or unpredictable execution model instead of fixing the underlying performance constraints.</p><h3>The Real Bottleneck (The Kernel)</h3><p>To understand where these problems come from, you need to look at what actually happens to a packet.</p><p>When you send or receive a packet, it doesn’t go straight from your application to the network. Each packet must cross the OS boundary:</p><ul><li>system call into the kernel</li><li>possible context switch</li><li>processing on the kernel stack</li><li>interrupt handling</li><li>scheduler deciding who runs next</li></ul><p>All of this adds overhead and timing variability (jitter).</p><p>Even if your application code is fast, at high packet rates the per-packet cost is dominated by the OS.</p><p>NIC → Kernel → Userspace → Kernel → NIC</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*LHF-iplZQyo-XP8PL8dySg.png" /></figure><h3>How hard is 1M Packert/Sec</h3><p>Even 1M packets/sec is tough because it leaves you only 1 microsecond per packet — there’s no room for extra overhead.​</p><ul><li>1,000,000 packets/sec means 1 packet every 1 µs.</li></ul><h4>How to receive a million packets per second​ ?</h4><ul><li>A single Linux context switch can cost around 1.2–1.5 µs in a best-case, pinned scenario, and it can be ~2.2 µs without pinning.​</li><li>So you can be “late” before you even start parsing the packet payload, because the OS overhead can consume the entire per-packet budget.</li></ul><h3>The Performance Wall</h3><p>At this point, many engineers try the traditional fixes:</p><ul><li>Add more threads</li><li>Add more async</li><li>Add more abstraction</li></ul><p>But these don’t remove the real cost — they often multiply it.</p><p>More threads → more contention and context switches<br>More async → less waiting, but same CPU cost<br>More abstraction → more layers between you and hardware</p><p>Eventually, you hit a wall where no amount of clever code helps.</p><p>Performance stops being a software problem.<br>It becomes a system architecture problem.</p><p>That’s when DPDK becomes the right tool.</p><h3>Introduction to DPDK</h3><p>DPDK exists because, at a certain scale, you have to take the kernel out of the hot path. DPDK (Data Plane Development Kit) is a set of libraries and drivers used to build high-performance packet-processing applications — especially in SDN and NFV.</p><p>It runs in user space (most commonly on x86 systems) and is designed for extremely high throughput and low latency. Instead of pushing every packet through the kernel’s networking stack, DPDK lets your application interact much more directly with the NIC and process packets in user space, cutting a large chunk of per-packet overhead and making performance far more predictable.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=770ed8a2453e" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[C++ HTTP/HTTPS Requests: Raw Sockets vs. libcurl — A Practical Guide]]></title>
            <link>https://medium.com/@abdallahrabie45/c-http-https-requests-raw-sockets-vs-libcurl-a-practical-guide-21750689db55?source=rss-b976f647e182------2</link>
            <guid isPermaLink="false">https://medium.com/p/21750689db55</guid>
            <category><![CDATA[cpp-programming]]></category>
            <category><![CDATA[https]]></category>
            <category><![CDATA[socket-programming]]></category>
            <category><![CDATA[curl]]></category>
            <dc:creator><![CDATA[Abdallah rabie]]></dc:creator>
            <pubDate>Tue, 08 Apr 2025 14:39:19 GMT</pubDate>
            <atom:updated>2025-04-08T14:39:19.072Z</atom:updated>
            <content:encoded><![CDATA[<h3>C++ HTTP/HTTPS Requests: Raw Sockets vs. libcurl — A Practical Guide</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*2ajj-xIueH6mKrbJ" /></figure><h3>How to handle HTTP/HTTPS request in cpp</h3><p>When working with web APIs or network communication in C++, you have two main approaches: using raw sockets (lower-level) or a library like cURL (higher-level). Here’s a comparison with code examples for both methods.</p><h3>Using Raw Sockets (Lower-Level Approach) (<a href="https://learn.microsoft.com/en-us/windows/win32/winsock/tcp-ip-raw-sockets-2">https://learn.microsoft.com/en-us/windows/win32/winsock/tcp-ip-raw-sockets-2</a>)</h3><p>A raw socket is a type of socket that allows access to the underlying transport provider. This topic focuses only on raw sockets and the IPv4 and IPv6 protocols. This is because most other protocols with the exception of ATM do not support raw sockets. To use raw sockets, an application needs to have detailed information on the underlying protocol being used.</p><h3>Using libcurl (Higher-Level Approach) (<a href="https://curl.se/libcurl/">https://curl.se/libcurl/</a>)</h3><p>libcurl is a free and easy-to-use client-side URL transfer library, supporting DICT, FILE, FTP, FTPS, GOPHER, GOPHERS, HTTP, HTTPS, IMAP, IMAPS, LDAP, LDAPS, MQTT, POP3, POP3S, RTMP, RTMPS, RTSP, SCP, SFTP, SMB, SMBS, SMTP, SMTPS, TELNET, TFTP, WS and WSS. libcurl supports SSL certificates, HTTP POST, HTTP PUT, FTP uploading, HTTP form based upload, proxies, HTTP/2, HTTP/3, cookies, user+password authentication (Basic, Digest, NTLM, Negotiate, Kerberos), file transfer resume, http proxy tunneling and more! libcurl is highly portable, it builds and works identically on numerous platforms, including Solaris, NetBSD, FreeBSD, OpenBSD, Darwin, HPUX, IRIX, AIX, Tru64, Linux, UnixWare, HURD, Windows, Amiga, OS/2, BeOs, macOS, Ultrix, QNX, OpenVMS, RISC OS, Novell NetWare, DOS and more… libcurl is free, thread-safe, IPv6 compatible, feature rich, well supported, fast, thoroughly documented and is already used by many known, big and successful companies.</p><h3>In this example i will use CURL</h3><ul><li>Include the library</li></ul><pre>#include &lt;curl/curl.h&gt;</pre><ul><li>Declear the object</li><li>CURL *curl; CURLcode res;</li><li>curl_easy_init() is the fundamental function in libcurl that initializes a new easy handle (a CURL object) for performing HTTP requests curl_easy_init() returns either:</li><li>A valid pointer to a new CURL handle (success)</li><li>NULL if initialization failed (very rare). curl= curl_easy_init();</li><li>The if(curl) check is verifying whether the curl_easy_init() call successfully created a new CURL easy handle. if(curl)</li><li>curl_easy_setopt is used to tell libcurl how to behave. By setting the appropriate options</li></ul><pre>curl_easy_setopt(curl,CURLOPT_URL,&quot;http://google.com&quot;); // Purpose: Sets the URL for the HTTP request<br>      curl_easy_setopt(curl,CURLOPT_WRITEFUNCTION,WriteCallback);  //Purpose: Defines how received data should be handled <br>      //WriteCallback: Your custom function that processes incoming data<br>      curl_easy_setopt(curl,CURLOPT_WRITEDATA,&amp;readBuffer); //Purpose: Passes your data buffer to the callback function</pre><ul><li>curl_easy_perform performs a network transfer in a blocking manner and returns when done, or earlier if it fails. For non-blocking behavior</li></ul><pre>res =curl_easy_perform(curl); // Return when done performing<br>      if(res!=CURLE_OK){ // <br>          std::cerr&lt;&lt;&quot;Curl error: &quot;&lt;&lt;curl_easy_strerror(res) &lt;&lt;std::endl; // Print if there an Isuse<br>      }else{<br>          std::cout&lt;&lt;&quot;Response: \n&quot;&lt;&lt;readBuffer&lt;&lt;std::endl;<br>      }</pre><ul><li>After finshing you have to Frees all resources associated with that handle and Required for every curl_easy_init() call to prevent memory leaks</li></ul><pre>curl_easy_cleanup(curl);<br>curl_global_cleanup();  // Shuts down all libcurl functionality and Releases all global resources (SSL, WinSock, etc.)</pre><p>This is the whole code to try</p><pre>#include &lt;curl/curl.h&gt;<br>#include&lt;iostream&gt;<br><br>static size_t WriteCallback(void *contents,size_t size,size_t nmemb,std::string *response){<br>    size_t totalSize =size *nmemb;<br>    response-&gt;append((char*) contents,totalSize);<br>    return totalSize;<br>}<br><br>int main(){<br>    CURL *curl;<br>    CURLcode res;<br>    std::string readBuffer;<br>    curl= curl_easy_init();<br>    if(curl){<br>        curl_easy_setopt(curl,CURLOPT_URL,&quot;http://google.com&quot;);<br>        curl_easy_setopt(curl,CURLOPT_WRITEFUNCTION,WriteCallback);<br>        curl_easy_setopt(curl,CURLOPT_WRITEDATA,&amp;readBuffer);<br>        res =curl_easy_perform(curl);<br>        if(res!=CURLE_OK){<br>            std::cerr&lt;&lt;&quot;Curl error: &quot;&lt;&lt;curl_easy_strerror(res) &lt;&lt;std::endl;<br>        }else{<br>            std::cout&lt;&lt;&quot;Response: \n&quot;&lt;&lt;readBuffer&lt;&lt;std::endl;<br>        }<br>          curl_easy_cleanup(curl);<br>    }<br>    curl_global_cleanup();<br>        return 0;<br>}</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/713/1*ObcnruUyWXUVkcZ6RKnnqQ.png" /></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=21750689db55" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Handling JSON in Modern C++ with nlohmann/json Library]]></title>
            <link>https://medium.com/@abdallahrabie45/handling-json-in-modern-c-with-nlohmann-json-library-214b2e50453a?source=rss-b976f647e182------2</link>
            <guid isPermaLink="false">https://medium.com/p/214b2e50453a</guid>
            <category><![CDATA[json]]></category>
            <category><![CDATA[cpp]]></category>
            <dc:creator><![CDATA[Abdallah rabie]]></dc:creator>
            <pubDate>Tue, 08 Apr 2025 13:35:31 GMT</pubDate>
            <atom:updated>2025-04-08T14:40:18.003Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*nP36TioODB1cahkR" /></figure><p>JSON (JavaScript Object Notation) has become the de facto standard for data interchange in modern applications. In C++, there are several approaches to work with JSON data, ranging from manual parsing to using robust libraries. Why JSON in C++? Web APIs: Most web services use JSON for requests/responses Configuration files: Human-readable format for settings Data serialization: Store and transfer structured data Interoperability: Easily exchange data with other languages/apps</p><h3>Using nlohmann/json (<a href="https://github.com/nlohmann/json">https://github.com/nlohmann/json</a>)</h3><ul><li>In this exaple we will use nlogmann library</li><li>In Linux download sudo apt-get install nlohmann-json3-dev</li><li>First lets create type alias for the library</li></ul><pre>#include &lt;nlohmann/json.hpp&gt; // import the library<br>using json = nlohmann::json; // type alias the constractor</pre><ul><li>Then create JSON object</li></ul><pre>json j_object = {<br>        {&quot;name&quot;, &quot;John Doe&quot;},<br>        {&quot;age&quot;, 30},<br>        {&quot;is_student&quot;, false},<br>        {&quot;skills&quot;, {&quot;C++&quot;, &quot;Python&quot;, &quot;JavaScript&quot;}}<br>    };</pre><ul><li>Print the object in terminal</li></ul><pre>std::cout &lt;&lt; &quot;Original JSON object:\n&quot; &lt;&lt; j_object.dump() &lt;&lt; std::endl;</pre><ul><li>Dump function is used to serialize the obejct with pretty printing you can pass the amount of spaces by passing the dump function the number of spacing</li><li>j_object.dump()</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/861/1*nzfs9zC4Esy_x_5bQ9BH-A.png" /></figure><ul><li>j_object.dump(4)</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/396/1*i-MgX4UOMi24w6A12m_y2Q.png" /></figure><ul><li>You can also acess and modify the values of the JSON</li></ul><pre>j_object[&quot;age&quot;] = 31;  // Update age<br>    j_object[&quot;skills&quot;].push_back(&quot;Rust&quot;);  // Add a new skill</pre><p>this is the whole code</p><pre>#include &lt;iostream&gt;<br>#include &lt;nlohmann/json.hpp&gt;<br>using json = nlohmann::json;<br>int main() {<br>    // Create a JSON object<br>    json j_object = {<br>        {&quot;name&quot;, &quot;John Doe&quot;},<br>        {&quot;age&quot;, 30},<br>        {&quot;is_student&quot;, false},<br>        {&quot;skills&quot;, {&quot;C++&quot;, &quot;Python&quot;, &quot;JavaScript&quot;}}<br>    };<br>    // Print the JSON object<br>    std::cout &lt;&lt; &quot;Original JSON object:\n&quot; &lt;&lt; j_object.dump() &lt;&lt; std::endl;<br>    // Access and modify values<br>    j_object[&quot;age&quot;] = 31;  // Update age<br>    j_object[&quot;skills&quot;].push_back(&quot;Rust&quot;);  // Add a new skill<br>    // Serialize the updated JSON object<br>    std::cout &lt;&lt; &quot;\nUpdated JSON object:\n&quot; &lt;&lt; j_object.dump(2) &lt;&lt; std::endl;<br>    return 0;<br>}</pre><ul><li>You can check the link of the library to get more infos</li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=214b2e50453a" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Java threading]]></title>
            <link>https://medium.com/@abdallahrabie45/java-threading-5a0155915d40?source=rss-b976f647e182------2</link>
            <guid isPermaLink="false">https://medium.com/p/5a0155915d40</guid>
            <category><![CDATA[threads]]></category>
            <category><![CDATA[threading]]></category>
            <category><![CDATA[java]]></category>
            <dc:creator><![CDATA[Abdallah rabie]]></dc:creator>
            <pubDate>Mon, 07 Oct 2024 09:10:32 GMT</pubDate>
            <atom:updated>2024-10-07T09:10:32.922Z</atom:updated>
            <content:encoded><![CDATA[<ul><li>Java threading is a fundamental concept that allows concurrent execution of code, enabling applications to perform multiple tasks simultaneously.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/276/0*UW_bB6wgzLYpXdyR" /></figure><h3>What is a Thread?</h3><ul><li>A thread in Java is a lightweight subprocess, the smallest unit of processing that can be scheduled by the operating system. Each thread has its own call stack, program counter, and local variables, allowing for independent execution within a program.</li></ul><h3>Types</h3><h3>Daemon Thread (system thread)</h3><ul><li>Type of thread that runs in the background and does not prevent the Java Virtual Machine (JVM) from exiting when all non-daemon threads have completed.</li><li>Key Tasks Managed by Daemon Threads</li><li>Garbage Collection Garbage collection is the process of automatically identifying and reclaiming memory that is no longer in use, which helps in preventing memory leaks and optimizing memory usage.</li><li>Event Dispatching In GUI applications, event dispatching is crucial for handling user interactions, such as button clicks, mouse movements, or keyboard inputs.</li><li>Background Monitoring Applications may need to monitor various system resources or application states (like performance metrics or network connectivity).</li></ul><h3><strong>User thread</strong></h3><ul><li>User threads are the primary threads created by applications to perform specific tasks concurrently. Unlike daemon threads, user threads run in the foreground and are essential for the application’s execution. Enables concurrent execution, dividing tasks for improved performance.</li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=5a0155915d40" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Qt application with yocto]]></title>
            <link>https://medium.com/@abdallahrabie45/qt-application-with-yocto-5d8c5f955539?source=rss-b976f647e182------2</link>
            <guid isPermaLink="false">https://medium.com/p/5d8c5f955539</guid>
            <category><![CDATA[qt]]></category>
            <category><![CDATA[sato]]></category>
            <category><![CDATA[yocto]]></category>
            <category><![CDATA[kpo]]></category>
            <category><![CDATA[embedded-linux]]></category>
            <dc:creator><![CDATA[Abdallah rabie]]></dc:creator>
            <pubDate>Wed, 28 Aug 2024 10:24:43 GMT</pubDate>
            <atom:updated>2024-08-28T10:24:43.643Z</atom:updated>
            <content:encoded><![CDATA[<p>Creating a Yocto image with Qt support involves several steps, including configuring the build environment, adding the necessary layers, and customizing the build configuration to include Qt. Below is a step-by-step guide to creating a Yocto image with Qt</p><h3>Steps</h3><ul><li>In this Demo we will use sato image</li><li>First clone qt layer in yocto path git clone -b kirkstone <a href="https://github.com/meta-qt5/meta-qt5.git">https://github.com/meta-qt5/meta-qt5.git</a></li><li>Source poky source oe-init-build-env build</li><li>Add the QT layer bitbake-layers add-layer ../meta-qt5</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/717/0*iXlWaVAa_7acK8MS" /></figure><ul><li>Edit local.conf to add recipes for qt</li></ul><pre>IMAGE_INSTALL:append = &quot; qtbase qtdeclarative qtquickcontrols qtbase-tools qtbase-plugins qtexamples&quot;<br>DISTRO_FEATURES:append = &quot; wayland opengl wifi pam&quot;<br>CORE_IMAGE_EXTRA_INSTALL += &quot;wayland weston&quot;<br>IMAGE_FEATURES += &quot; x11-sato x11 &quot;<br>IMAGE_INSTALL:append = &quot; x11vnc&quot;<br>IMAGE_INSTALL:append = &quot; mesa&quot;<br>PREFERRED_PROVIDER_virtual/libgl = &quot;mesa&quot;</pre><ul><li>IMAGE_INSTALL:append = “ qtbase qtdeclarative qtquickcontrols qtbase-tools qtbase-plugins”:</li><li>This appends several Qt-related packages to the list of packages that will be included in your image. qtbase: The core Qt module providing basic classes and tools for developing Qt applications. qtdeclarative: Provides support for QML and JavaScript-based applications. qtquickcontrols: Contains pre-built UI components (buttons, sliders, etc.) for use in QML. qtbase-tools: Provides tools related to the Qt base module (e.g., qmake). qtbase-plugins: Adds additional plugins to Qt (e.g., platform plugins like EGLFS, XCB, etc.). qtexample: for my application name</li><li>DISTRO_FEATURES:append = “ wayland opengl wifi pam”:</li><li>wayland: Adds support for the Wayland display server protocol, a modern alternative to X11. opengl: Enables OpenGL support, crucial for hardware-accelerated graphics. wifi: Ensures Wi-Fi support is included in your image. pam: Adds Pluggable Authentication Modules (PAM) for handling authentication tasks.</li><li>CORE_IMAGE_EXTRA_INSTALL += “wayland weston”:</li><li>wayland: Adds the Wayland protocol and libraries. weston: Weston is the reference compositor for Wayland. This means that your image will have the capability to run Wayland sessions.</li><li>IMAGE_FEATURES += “ x11-sato x11 “:</li><li>x11-sato: Adds the Sato environment, which is a lightweight graphical environment commonly used in embedded systems. x11: Ensures that basic X11 support is included. Even though Wayland is included, X11 support is still available.</li><li>IMAGE_INSTALL:append = “ x11vnc”:</li><li>x11vnc: A VNC server that allows remote access to the X11 display. This lets you view and interact with the desktop environment on another machine.</li><li>IMAGE_INSTALL:append = “ mesa”:</li><li>mesa: An open-source implementation of the OpenGL specification. It provides software rendering support and can also interface with hardware-accelerated graphics drivers. Mesa provides the libGL implementation, which is crucial for applications requiring OpenGL.</li><li>PREFERRED_PROVIDER_virtual/libgl = “mesa”:</li><li>This line sets mesa as the preferred provider for the virtual libgl library. In Yocto, virtual/libgl is a virtual target that different implementations (such as Mesa or proprietary GPU drivers) can provide. By setting mesa as the preferred provider, you’re ensuring that the Mesa implementation of OpenGL is used.</li></ul><h3>Create QT app</h3><ul><li>The Hello World application consists of multiple files (main.cpp mainwindow.cpp mainwondow.hpp mainwindow.ui main.pro)</li><li>Make a project with QT Creator and make it empty</li><li>Rewrite the ```main.pro`` file to work with yocto</li></ul><pre>QT       += core gui</pre><pre>greaterThan(QT_MAJOR_VERSION, 4): QT += widgets<br></pre><pre>TARGET = myqtapp<br>TEMPLATE = app</pre><pre>SOURCES += \<br>    main.cpp \<br>    mainwindow.cpp</pre><pre>HEADERS += \<br>    mainwindow.h</pre><pre>FORMS += \<br>    mainwindow.ui</pre><h3>Lets inject the app in yocto</h3><ul><li>Go to ur cutsom layer if you dont create one</li><li>mkdir recipes-application</li><li>cd recipes-application</li><li>mkdir recipes-qt/files</li><li>cd recipes-qt</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/335/0*39VklrFVGI7sLdj_" /></figure><ul><li>Create application recipe touch qtexample_0.1.bb</li><li>Write the recipe for the application</li></ul><pre>SUMMARY = &quot;Sample Qt5 Application&quot;<br>DESCRIPTION = &quot;This is a sample Qt5 application.&quot;<br>LICENSE = &quot;CLOSED&quot;<br></pre><pre>SRC_URI = &quot;file://main.pro \<br>            file://main.cpp \<br>            file://mainwindow.cpp \<br>            file://mainwindow.h \<br>            file://mainwindow.ui \<br>            file://ui_mainwindow.h&quot;</pre><pre>DEPENDS += &quot;qtbase wayland&quot;<br>RDEPENDS_${PN} += &quot;qtwayland&quot;</pre><pre>S = &quot;${WORKDIR}&quot;</pre><pre>inherit qmake5</pre><pre>do_install:append() {<br>    install -d ${D}${bindir}<br>    install -m 0775 myqtapp ${D}${bindir}<br>}<br>FILES_${PN} += &quot;${bindir}/myqtapp&quot;</pre><ul><li>But the QT files in files directory</li></ul><h3>Build image</h3><ul><li>bitbake core-image-sato</li><li>Then put the image in sdcard and connect</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*oGasXwE9wNJlp50t" /></figure><ul><li>Press weston</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*I8dPZURzLgZ4Piom" /></figure><ul><li>Write ur app name ```myqtapp``</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*KGYqYeidqs0zs9Rg" /></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=5d8c5f955539" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Create custom image for ignition using yocto]]></title>
            <link>https://medium.com/@abdallahrabie45/create-custom-image-for-ignition-using-yocto-3e8f4a4e29c8?source=rss-b976f647e182------2</link>
            <guid isPermaLink="false">https://medium.com/p/3e8f4a4e29c8</guid>
            <category><![CDATA[ignition]]></category>
            <category><![CDATA[yocto]]></category>
            <category><![CDATA[linux]]></category>
            <category><![CDATA[iiot]]></category>
            <category><![CDATA[industry]]></category>
            <dc:creator><![CDATA[Abdallah rabie]]></dc:creator>
            <pubDate>Thu, 15 Aug 2024 07:04:03 GMT</pubDate>
            <atom:updated>2024-08-15T07:04:03.201Z</atom:updated>
            <content:encoded><![CDATA[<p>Creating a custom Yocto image that includes Ignition requires several steps. You’ll need to configure Yocto to build a custom image with all the necessary components, including Ignition.</p><h3>What is ignition?</h3><ul><li>Ignition is a comprehensive industrial automation software platform developed by Inductive Automation. It is widely used in manufacturing and industrial settings for Supervisory Control and Data Acquisition (SCADA), Human-Machine Interface (HMI), and Industrial Internet of Things (IIoT) applications.</li></ul><h3>Key Features of Ignition:</h3><ul><li>SCADA and HMI: Ignition is primarily used for creating SCADA systems that allow operators to monitor and control industrial processes. It also provides tools to create HMIs that enable interaction with machinery and equipment.</li><li>Unlimited Licensing Model: One of Ignition’s standout features is its licensing model, which allows unlimited clients, tags, and connections for a flat fee, making it cost-effective for large-scale deployments.</li><li>Web-Based Interface: Ignition’s interface is web-based, meaning it can be accessed from any device with a web browser, making it highly versatile and accessible.</li><li>IIoT Capabilities: Ignition supports IIoT by integrating with various industrial protocols, databases, and cloud services, allowing seamless data collection, processing, and analysis.</li><li>Modularity: Ignition is highly modular, with various add-ons and modules that can be used to extend its functionality, such as reporting, alarm notifications, and enterprise administration.</li><li>Cross-Platform: Ignition runs on Windows, Linux, and macOS, providing flexibility in deployment.</li><li>Database Integration: It integrates with SQL databases, enabling powerful data logging, retrieval, and analysis capabilities.</li><li>Scripting and Automation: Ignition supports Python scripting, allowing users to automate tasks, customize functionalities, and create complex logic within the platform.</li></ul><h3>Use Cases:</h3><ul><li>Manufacturing: Monitoring and controlling production lines, tracking performance metrics, and managing alarms. Energy Management: Managing energy usage, monitoring critical systems, and ensuring compliance with energy standards. Water Treatment: Monitoring water quality, controlling treatment processes, and ensuring regulatory compliance. Building Automation: Managing HVAC systems, lighting, and security systems within buildings.</li></ul><p>For more information <a href="https://inductiveautomation.com/ignition/">https://inductiveautomation.com/ignition/</a></p><h3>Add ignition to the customized image</h3><ul><li>You have two ways:</li><li>The hard way to install the requirements to the local.conf file and to create the recipe to install ignition locally</li><li>the easy way to add docker to the custom image and pull the docker image from docker hub</li></ul><h3>The easy way</h3><h4>First let’s add docker</h4><ul><li>Let’s add the meta-virtualization layer first go to poky git clone <a href="https://git.yoctoproject.org/meta-virtualization">https://git.yoctoproject.org/meta-virtualization</a></li><li>Source the enviroment source oe-init-build-env</li><li>Add the layer bitbake-layers add-layer ../meta-virtualization</li><li>U would get that error probably</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*HT2f43sHAEnS1JHZ" /></figure><ul><li>This error tells u to add this layer also bitbake-layers add-layer ../meta-openembedded/meta-filesystems</li><li>Then do this again bitbake-layers add-layer ../meta-virtualization</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/825/0*hhdoEZpCF4Se9eYh" /></figure><ul><li>DONE HERE</li></ul><h3>Local.conf File</h3><ul><li>Add these 2 lines</li></ul><pre>DISTRO_FEATURES:append = &quot; virtualization&quot;<br>IMAGE_INSTALL:append = &quot; docker-ce&quot;</pre><ul><li>DISTRO_FEATURES defines the features and capabilities that are included in the distribution. This can include support for various packages, libraries, or system capabilities.</li><li>IMAGE_INSTALL specifies the list of packages that should be installed in the final image. This directly affects the contents of the image being built.</li><li>For space use this IMAGE_ROOTFS_SIZE = &quot;2194304&quot;</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/745/0*0wfrZcrscK_Isz49" /></figure><ul><li>Bingo docker is working now</li></ul><h4>Second let’s pull the ignition</h4><ul><li>Go to <a href="https://hub.docker.com/r/inductiveautomation/ignition">https://hub.docker.com/r/inductiveautomation/ignition</a></li><li>Go to Tages and choose the version</li><li>docker pull inductiveautomation/ignition:nightly</li><li>Docker image is already installed it may take a while</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/763/0*lg2F2Sj3PEdDboAD" /></figure><ul><li>Use the command given by the ignition to run the docker image</li></ul><pre>docker run -d -p 9088:8088 --name ignition-test inductiveautomation/ignition:8.1.42 \<br>    -n docker-test -a localhost -h 9088 -s 9043</pre><ul><li>Use docker ps command to see the docker containers that working now</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*H2pxtWw2T-SixWqF" /></figure><ul><li>Working now let’s try it</li><li>Know the ip of ur device UR-IP:9088</li><li>It is working!</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*TeYMII6BlKKKGu7D" /></figure><h3>Tips</h3><ul><li>Docker image is very large don’t forget to add extra rootfs space in ur image</li><li>Check this variable IMAGE_ROOTFS_SIZE</li><li><a href="https://docs.yoctoproject.org/1.8/ref-manual/ref-manual.html">https://docs.yoctoproject.org/1.8/ref-manual/ref-manual.html</a></li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*9oUtEGwvua8-yYDX" /></figure><ul><li>Do not forget to check the requirements of the device to install the ignition</li><li><a href="https://www.docs.inductiveautomation.com/docs/8.1/getting-started/quick-start-guide/download-and-install">https://www.docs.inductiveautomation.com/docs/8.1/getting-started/quick-start-guide/download-and-install</a></li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/915/0*fxfJL3Vb5-YjxWiw" /></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=3e8f4a4e29c8" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[How to add docker image with yocto]]></title>
            <link>https://medium.com/@abdallahrabie45/how-to-add-docker-image-with-yocto-c504b0a21bb2?source=rss-b976f647e182------2</link>
            <guid isPermaLink="false">https://medium.com/p/c504b0a21bb2</guid>
            <category><![CDATA[yocto]]></category>
            <category><![CDATA[docker]]></category>
            <category><![CDATA[pokies]]></category>
            <category><![CDATA[neurons]]></category>
            <dc:creator><![CDATA[Abdallah rabie]]></dc:creator>
            <pubDate>Wed, 07 Aug 2024 11:54:57 GMT</pubDate>
            <atom:updated>2024-08-07T11:54:57.187Z</atom:updated>
            <content:encoded><![CDATA[<p>Adding Docker to a Yocto image involves several steps, including adding the necessary layers, updating the local.conf, and adding Docker to your image.</p><h3>Steps</h3><ul><li>Lets add the meta-virtulization layer first go to poky git clone <a href="https://git.yoctoproject.org/meta-virtualization">https://git.yoctoproject.org/meta-virtualization</a></li><li>Source the enviroment source oe-init-build-env</li><li>Add the layer bitbake-layers add-layer ../meta-virtualization</li><li>U would get that error probaply</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*ihOpPtFzClLOZuIQ" /></figure><ul><li>This error tells u to add this layer also bitbake-layers add-layer ../meta-openembedded/meta-filesystems</li><li>Then do this again bitbake-layers add-layer ../meta-virtualization</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/825/0*u-w5FfKSSX1J5aZ7" /></figure><ul><li>DONE HERE</li></ul><h3>Local.conf File</h3><ul><li>Add this 2 lines</li></ul><pre>DISTRO_FEATURES:append = &quot; virtualization&quot;<br>IMAGE_INSTALL:append = &quot; docker-ce&quot;</pre><ul><li>DISTRO_FEATURES defines the features and capabilities that are included in the distribution. This can include support for various packages, libraries, or system capabilities.</li><li>IMAGE_INSTALL specifies the list of packages that should be installed in the final image. This directly affects the contents of the image being built.</li><li>For space space use this IMAGE_ROOTFS_SIZE = &quot;2194304&quot;</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/745/0*NKQaFrnN_VQNgcBN" /></figure><ul><li>Bingo docker is working now</li></ul><h3>Neuron docker image</h3><ul><li>Neuron is an open-source, lightweight IIoT connectivity server that empowers industrial devices with the key IoT connectivity capabilities in the Industry 4.0 era.</li><li>Pull the image docker pull emqx/neuron-en</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/712/0*nwhzNrRvfe4fzuut" /></figure><ul><li>Already downloaded</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/601/0*Hnp2TiKSiFOKJNRZ" /></figure><ul><li>Run the contanier</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/779/0*1d84Pu3TvFysOPpk" /></figure><ul><li>I lanuched neruon at the rasbperry localhost and port 7000</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/738/0*GZV2fUUJrFcERP6D" /></figure><ul><li>Done !!</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*045vt1QxyF6Hy95m" /></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=c504b0a21bb2" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[How to detect memory leakage with valgrind]]></title>
            <link>https://medium.com/@abdallahrabie45/how-to-detect-memory-leakage-with-valgrind-795164f6f3c8?source=rss-b976f647e182------2</link>
            <guid isPermaLink="false">https://medium.com/p/795164f6f3c8</guid>
            <category><![CDATA[dynamic-memory-allocation]]></category>
            <category><![CDATA[cpp]]></category>
            <category><![CDATA[valgrind]]></category>
            <dc:creator><![CDATA[Abdallah rabie]]></dc:creator>
            <pubDate>Sun, 14 Jul 2024 07:58:33 GMT</pubDate>
            <atom:updated>2024-07-14T07:58:33.007Z</atom:updated>
            <content:encoded><![CDATA[<p>First lets write a simple code without any leakage</p><pre>#include &lt;iostream&gt;<br><br><br>int main(){<br><br>int i;<br>float *ptr;<br>std::cout&lt;&lt; &quot;Enter the arrary size&quot; &lt;&lt; std::endl;<br>std::cin&gt;&gt; i;<br>ptr =new float[i];<br>delete [] ptr;<br>    return 0;<br><br>}</pre><p>This simple script create an array of float and store this in the dynamic memory then delete this allocation</p><p>To run this with valgrind</p><pre>g++ main.cpp -o a.out <br>valgrind --leak-check=full ./a.out</pre><p>The output say that there is no leak</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/840/1*1zLC_Es0d7Y2xzAAN2Tslw.png" /></figure><p>Lets create some leak with deleting this line ptr =new float[i];</p><pre>#include &lt;iostream&gt;<br><br>int main(){<br><br>int i;<br>float *ptr;<br>std::cout&lt;&lt; &quot;Enter the arrary size&quot; &lt;&lt; std::endl;<br>std::cin&gt;&gt; i;<br>ptr =new float[i];<br>    return 0;<br><br>}</pre><pre>g++ main.cpp -o a.out <br>valgrind --leak-check=full ./a.out</pre><p>The output tells you that there is 20 bytes leak</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Wy5XGcVbKQZrz4yTQoG-Sg.png" /></figure><p>This leak because u locate dynamic memory without free the this space before program end</p><p>So why 20 byte due to size of float is 4 byte and the size of the array we use is 5 so 5*4=20 byte</p><p>So you have to free this memory location of this pointer</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=795164f6f3c8" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Mosquitto]]></title>
            <link>https://medium.com/@abdallahrabie45/mosquitto-dc572cd23618?source=rss-b976f647e182------2</link>
            <guid isPermaLink="false">https://medium.com/p/dc572cd23618</guid>
            <category><![CDATA[broker]]></category>
            <category><![CDATA[mosquitto]]></category>
            <category><![CDATA[mqtt]]></category>
            <dc:creator><![CDATA[Abdallah rabie]]></dc:creator>
            <pubDate>Wed, 10 Jul 2024 13:05:58 GMT</pubDate>
            <atom:updated>2024-07-10T13:05:58.569Z</atom:updated>
            <content:encoded><![CDATA[<p>Mosquitto is an open-source message broker that implements the MQTT (Message Queuing Telemetry Transport) protocol. MQTT is a lightweight, publish/subscribe network protocol that transports messages between devices. It is designed for connections with remote locations where a “small code footprint” is required or where network bandwidth is limited.</p><h3>Install Mosquitto</h3><ul><li>sudo apt-get install mosquitto mosquitto-clients -y to download mosquitto and the client</li><li>lets change some setting to be able to acsses the broker in local network sudo nano /etc/mosquitto/mosquitto.conf</li><li>listener 1883 0.0.0.0</li><li>use this command to start the Mosquitto sudo systemctl restart mosquitto</li></ul><h3>Install mqtt Client (MQTTX)</h3><ul><li><a href="https://mqttx.app/downloads">https://mqttx.app/downloads</a></li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*Z3pltjYQ-2nfuISZ" /></figure><ul><li>I used x86–64 | v1.10.0.deb</li><li>use this command to install the file after download sudo dpkg -i &lt;File_Name&gt;</li><li>Open it with writing mqttx in terminal</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*s_hh7JGJDObSVlOs" /></figure><h3>Inslal mqtt explorar</h3><ul><li><a href="http://mqtt-explorer.com/">http://mqtt-explorer.com/</a></li><li>snap install mqtt-explorer</li><li>use mqtt-explorer to open it</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*4Cldx_093_7VtnLi" /></figure><ul><li>Enter the localhost address -Now u can subscribe or publish from any client device and the explorar with find out</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*aXRsD5D71goMDn6M" /></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=dc572cd23618" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>