<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Pietro</title>
    <description>The latest articles on DEV Community by Pietro (@pietroth).</description>
    <link>https://dev.to/pietroth</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F4254488%2Fd3bfcef4-7576-467b-9f48-1216c1910f78.jpg</url>
      <title>DEV Community: Pietro</title>
      <link>https://dev.to/pietroth</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/pietroth"/>
    <language>en</language>
    <item>
      <title>I Migrated My C++26 Networking Library to C++17. Here's Why.</title>
      <dc:creator>Pietro</dc:creator>
      <pubDate>Thu, 19 Nov 2026 21:14:27 +0000</pubDate>
      <link>https://dev.to/pietroth/i-migrated-my-c26-networking-library-to-c17-heres-why-1a2f</link>
      <guid>https://dev.to/pietroth/i-migrated-my-c26-networking-library-to-c17-heres-why-1a2f</guid>
      <description>&lt;p&gt;A while ago, I started building LightnerX, a networking library for a multiplayer game I'm developing.&lt;/p&gt;

&lt;p&gt;When I first wrote it, I decided to use C++26 and modules. I liked the idea of using modern C++ features, and since I was developing everything myself, compatibility wasn't a huge concern.&lt;/p&gt;

&lt;p&gt;Then I released the library.&lt;/p&gt;

&lt;p&gt;And I started questioning that decision.&lt;/p&gt;

&lt;p&gt;The problem wasn't the language&lt;/p&gt;

&lt;p&gt;I actually enjoyed working with modules. Having explicit imports and organizing the library around modules felt pretty clean.&lt;/p&gt;

&lt;p&gt;But there was a practical issue.&lt;/p&gt;

&lt;p&gt;LightnerX is supposed to be integrated into other C++ projects. Requiring developers to use C++26, along with toolchains capable of handling modules, made that unnecessarily complicated.&lt;/p&gt;

&lt;p&gt;The library wasn't doing anything that fundamentally required C++26.&lt;/p&gt;

&lt;p&gt;Most of its functionality could work perfectly well with an older standard.&lt;/p&gt;

&lt;p&gt;So I decided to migrate the entire project to C++17.&lt;/p&gt;

&lt;p&gt;Goodbye, modules&lt;/p&gt;

&lt;p&gt;The first major change was replacing modules with traditional headers and implementation files.&lt;/p&gt;

&lt;p&gt;For example, instead of importing a module:&lt;/p&gt;

&lt;p&gt;import lightnerx.network.server;&lt;/p&gt;

&lt;p&gt;The C++17 version uses a header:&lt;/p&gt;

&lt;h1&gt;
  
  
  include 
&lt;/h1&gt;

&lt;p&gt;That sounds simple, but the migration involved more than changing "import" to "#include".&lt;/p&gt;

&lt;p&gt;The original project had 14 library modules. Their dependencies, declarations, and implementations needed to be reorganized while keeping the public functionality intact.&lt;/p&gt;

&lt;p&gt;I also had to revisit the CMake configuration, which previously depended on experimental module support.&lt;/p&gt;

&lt;p&gt;What about std::span and std::expected?&lt;/p&gt;

&lt;p&gt;This was another compatibility problem.&lt;/p&gt;

&lt;p&gt;"std::span" was introduced in C++20, while "std::expected" arrived in C++23.&lt;/p&gt;

&lt;p&gt;Neither belongs to C++17.&lt;/p&gt;

&lt;p&gt;I needed alternatives without giving up the functionality those types provided.&lt;/p&gt;

&lt;p&gt;The current LightnerX implementation uses "tcb::span" for non-owning byte views and "zeus::expected" for result handling.&lt;/p&gt;

&lt;p&gt;This allowed the library to preserve those programming patterns without requiring a newer language standard.&lt;/p&gt;

&lt;p&gt;Keeping the behavior consistent&lt;/p&gt;

&lt;p&gt;My main concern wasn't whether the new code would compile.&lt;/p&gt;

&lt;p&gt;It was whether changing the implementation would accidentally change how the library behaved.&lt;/p&gt;

&lt;p&gt;LightnerX handles connections, message interpretation, callbacks, and outgoing message batching. Those components have plenty of places where small mistakes can cause problems.&lt;/p&gt;

&lt;p&gt;I had already learned that lesson during an earlier technical audit, when I discovered a bug involving connection ID recycling after repeated connection cycles.&lt;/p&gt;

&lt;p&gt;For the migration, automated tests and technical reviews were essential.&lt;/p&gt;

&lt;p&gt;I wanted the C++17 version to preserve the same communication model and behavior, including error handling and message ownership.&lt;/p&gt;

&lt;p&gt;The goal was compatibility, not redesigning the library.&lt;/p&gt;

&lt;p&gt;Was it worth it?&lt;/p&gt;

&lt;p&gt;For this project, I think so.&lt;/p&gt;

&lt;p&gt;I still like modern C++, and I don't think using modules was inherently a bad decision.&lt;/p&gt;

&lt;p&gt;But I was building a reusable library, not just an application for myself.&lt;/p&gt;

&lt;p&gt;That changed my priorities.&lt;/p&gt;

&lt;p&gt;The library now targets C++17, uses traditional public headers, and can be integrated without requiring experimental C++ module support.&lt;/p&gt;

&lt;p&gt;There's still plenty of work ahead, but at least the language standard is no longer such a significant barrier.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://github.com/pietroth/LightnerX" rel="noopener noreferrer"&gt;&lt;/a&gt;&lt;/p&gt;

</description>
      <category>cpp</category>
      <category>programming</category>
      <category>opensource</category>
      <category>network</category>
    </item>
    <item>
      <title>I Designed a Communication Protocol Around Four Message Types</title>
      <dc:creator>Pietro</dc:creator>
      <pubDate>Thu, 19 Nov 2026 21:01:27 +0000</pubDate>
      <link>https://dev.to/pietroth/i-designed-a-communication-protocol-around-four-message-types-4mln</link>
      <guid>https://dev.to/pietroth/i-designed-a-communication-protocol-around-four-message-types-4mln</guid>
      <description>&lt;p&gt;While developing a multiplayer game in C++, I ran into an interesting problem: how should clients and servers communicate in a way that makes the meaning of each message explicit?&lt;/p&gt;

&lt;p&gt;Most networking solutions focus on transporting data. But I wanted to explore a different question:&lt;/p&gt;

&lt;p&gt;What if the communication model itself could describe the purpose of every message?&lt;/p&gt;

&lt;p&gt;That question eventually led me to design INER, a semantic communication protocol based on four message types.&lt;/p&gt;

&lt;p&gt;The idea behind INER&lt;/p&gt;

&lt;p&gt;INER stands for:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Intention: A client requests an action that may change the server's state.&lt;/li&gt;
&lt;li&gt;Notification: A client sends information without requesting a state change.&lt;/li&gt;
&lt;li&gt;Event: The server communicates something that has happened.&lt;/li&gt;
&lt;li&gt;Response: The server communicates the result of an intention.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The protocol defines two roles: Authority and Obedient.&lt;/p&gt;

&lt;p&gt;The Authority controls the authoritative state, while the Obedient communicates with it through structured messages.&lt;/p&gt;

&lt;p&gt;In a typical multiplayer game, the server acts as the Authority and the client acts as the Obedient.&lt;/p&gt;

&lt;p&gt;A simple example&lt;/p&gt;

&lt;p&gt;Imagine a multiplayer survival game.&lt;/p&gt;

&lt;p&gt;A player wants to open a door.&lt;/p&gt;

&lt;p&gt;Instead of sending a generic message, the client sends an Intention requesting that action.&lt;/p&gt;

&lt;p&gt;The server validates the request and sends back a Response, indicating whether the action was approved, denied, partially approved, or failed.&lt;/p&gt;

&lt;p&gt;If the door opens, the server can communicate that occurrence through an Event.&lt;/p&gt;

&lt;p&gt;Now imagine the client wants to report information that does not request an authoritative state change. That can be expressed through a Notification.&lt;/p&gt;

&lt;p&gt;These distinctions are simple, but they establish explicit responsibilities for each message.&lt;/p&gt;

&lt;p&gt;What INER does not do&lt;/p&gt;

&lt;p&gt;An important design decision was keeping the protocol independent of networking technology.&lt;/p&gt;

&lt;p&gt;INER does not define:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Sockets or connections&lt;/li&gt;
&lt;li&gt;TCP, UDP, or another transport&lt;/li&gt;
&lt;li&gt;Thread management&lt;/li&gt;
&lt;li&gt;Application update loops&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;It describes message semantics and their representation.&lt;/p&gt;

&lt;p&gt;The networking implementation is a separate responsibility.&lt;/p&gt;

&lt;p&gt;This separation lets me reason about communication independently of how messages are physically delivered.&lt;/p&gt;

&lt;p&gt;From a protocol to a C++ library&lt;/p&gt;

&lt;p&gt;I eventually implemented INER in LightnerX, an open-source C++ networking library built around Valve's GameNetworkingSockets.&lt;/p&gt;

&lt;p&gt;LightnerX provides networking components, message interpretation, connection management, callbacks, and message batching.&lt;/p&gt;

&lt;p&gt;But INER itself is a separate concept.&lt;/p&gt;

&lt;p&gt;The protocol describes what messages mean. The library provides components for representing, interpreting, and transporting them.&lt;/p&gt;

&lt;p&gt;Is this abstraction useful?&lt;/p&gt;

&lt;p&gt;I'm still exploring the design and its tradeoffs.&lt;/p&gt;

&lt;p&gt;Four explicit message categories provide structure, but they also introduce conventions that applications must follow.&lt;/p&gt;

&lt;p&gt;I'm particularly interested in how other developers approach this problem.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Do you distinguish action requests from informational messages in your networking architecture?&lt;/li&gt;
&lt;li&gt;Do you use a similar message classification system?&lt;/li&gt;
&lt;li&gt;Would you prefer this kind of semantic separation, or does it introduce unnecessary complexity?&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;I'd love to hear how other developers design their client-server communication.&lt;/p&gt;

&lt;p&gt;GitHub: &lt;a href="https://github.com/pietroth/LightnerX" rel="noopener noreferrer"&gt;https://github.com/pietroth/LightnerX&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;This article was written with AI assistance and reviewed by the project author.&lt;/p&gt;

</description>
      <category>programming</category>
      <category>networking</category>
      <category>cpp</category>
      <category>architecture</category>
    </item>
  </channel>
</rss>
