<?xml version="1.0" encoding="utf-8"?><feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en"><generator uri="https://jekyllrb.com/" version="3.10.0">Jekyll</generator><link href="https://esettes.github.io/website/feed.xml" rel="self" type="application/atom+xml" /><link href="https://esettes.github.io/website/" rel="alternate" type="text/html" hreflang="en" /><updated>2026-08-19T18:13:18+02:00</updated><id>https://esettes.github.io/website/feed.xml</id><title type="html">Roxana Stancu | Software Developer</title><subtitle>Roxana Stancu&apos;s portfolio and technical blog about backend development, automation, systems, Linux, networking, and software development.</subtitle><author><name>Roxana Stancu</name></author><entry><title type="html">TCP does not deliver complete messages: framing in an IRC server</title><link href="https://esettes.github.io/website/blog/2026/08/18/tcp-no-entrega-mensajes-completos/" rel="alternate" type="text/html" title="TCP does not deliver complete messages: framing in an IRC server" /><published>2026-08-18T19:00:00+02:00</published><updated>2026-08-18T19:00:00+02:00</updated><id>https://esettes.github.io/website/blog/2026/08/18/tcp-no-entrega-mensajes-completos</id><content type="html" xml:base="https://esettes.github.io/website/blog/2026/08/18/tcp-no-entrega-mensajes-completos/"><![CDATA[<p>When testing an IRC server with <code class="language-plaintext highlighter-rouge">netcat</code>, it is easy to assume that every press of Enter
will deliver exactly one command to the server. TCP provides no such guarantee.</p>

<p>TCP transports an <strong>ordered stream of bytes</strong>. It preserves order and lets us detect when
the connection closes, but it does not know the logical boundaries of IRC messages.</p>

<!--more-->

<h2 id="three-valid-recv-results">Three valid recv() results</h2>

<p>If the client sends:</p>

<div class="language-text highlighter-rouge"><div class="highlight"><pre class="highlight"><code>NICK rox\r\n
USER roxana 0 * :Roxana Stancu\r\n
</code></pre></div></div>

<p>the server could receive:</p>

<ol>
  <li>Both commands in one call.</li>
  <li>One command per call.</li>
  <li>Fragments such as <code class="language-plaintext highlighter-rouge">NI</code>, <code class="language-plaintext highlighter-rouge">CK rox\r\nUSER ro</code>, and the remainder later.</li>
</ol>

<p>All three cases are valid from TCP’s perspective. We therefore must not process everything
returned by <code class="language-plaintext highlighter-rouge">recv()</code> as though it were a complete message.</p>

<h2 id="a-persistent-buffer-for-each-client">A persistent buffer for each client</h2>

<p>Each connection must preserve the bytes that do not yet form a complete line. The
conceptual algorithm is:</p>

<div class="language-text highlighter-rouge"><div class="highlight"><pre class="highlight"><code>append received bytes to the client buffer
while the buffer contains CRLF
    extract one complete line
    remove that line from the buffer
    parse and dispatch the command
keep the remaining partial data for the next read event
</code></pre></div></div>

<p>The last step is important. The remaining fragment is not an error and must not be
discarded: it may be the beginning of the next command.</p>

<h2 id="multiple-lines-in-one-read">Multiple lines in one read</h2>

<p>Processing only the first line is also insufficient. When several commands arrive together,
the server must keep extracting lines until the buffer no longer contains a complete
terminator. Processing order must match receive order.</p>

<p>This explains a common bug: manual tests work command by command but fail when a complete
registration block is pasted. The problem is not necessarily in <code class="language-plaintext highlighter-rouge">PASS</code>, <code class="language-plaintext highlighter-rouge">NICK</code>, or <code class="language-plaintext highlighter-rouge">USER</code>;
it may be in the layer that separates the TCP stream into IRC lines.</p>

<h2 id="limits-and-safety">Limits and safety</h2>

<p>An unbounded buffer would allow a client to send data indefinitely without completing a
line. A robust implementation must define:</p>

<ul>
  <li>The maximum accepted IRC line length.</li>
  <li>The maximum pending buffer size.</li>
  <li>Behavior for invalid data or a connection closed midway through a message.</li>
  <li>Tests for fragmentation, concatenation, and partial writes.</li>
</ul>

<h2 id="the-key-idea">The key idea</h2>

<p>Line-oriented protocols run on top of TCP, but their messages do not align with socket
reads. Framing is the application’s responsibility.</p>]]></content><author><name>Roxana Stancu</name></author><summary type="html"><![CDATA[A practical explanation of buffering and IRC message framing over TCP.]]></summary></entry><entry><title type="html">Designing irc-netlab: a reproducible lab for testing IRC</title><link href="https://esettes.github.io/website/blog/2026/08/17/disenando-irc-netlab/" rel="alternate" type="text/html" title="Designing irc-netlab: a reproducible lab for testing IRC" /><published>2026-08-17T18:00:00+02:00</published><updated>2026-08-17T18:00:00+02:00</updated><id>https://esettes.github.io/website/blog/2026/08/17/disenando-irc-netlab</id><content type="html" xml:base="https://esettes.github.io/website/blog/2026/08/17/disenando-irc-netlab/"><![CDATA[<p>A protocol test can send commands and check responses. A QA lab must also control
everything that happens before and after that exchange.</p>

<p><code class="language-plaintext highlighter-rouge">irc-netlab</code> is my project for building that environment around an IRC service.</p>

<!--more-->

<h2 id="the-complete-cycle">The complete cycle</h2>

<p>The first goal is not to support every imaginable scenario. It is to achieve a small,
reliable, and repeatable local cycle:</p>

<div class="language-text highlighter-rouge"><div class="highlight"><pre class="highlight"><code>validate
-&gt; start
-&gt; wait until ready
-&gt; report status
-&gt; stop
-&gt; clean up
-&gt; report result
</code></pre></div></div>

<p>Every step needs an observable result. If the service does not start, the lab must explain
why. If a test fails, it must preserve evidence. If execution ends unexpectedly, it must
still clean up the processes and resources it owns.</p>

<h2 id="independence-before-generalization">Independence before generalization</h2>

<p><code class="language-plaintext highlighter-rouge">irc-netlab</code> will be the first lab in an ecosystem that could include HTTP, TCP, DNS, or
WebSocket. That does not mean they should all share a large abstraction from day one.</p>

<p>The initial rules are:</p>

<ul>
  <li>Each lab exposes capabilities through public contracts.</li>
  <li>Labs do not depend on one another.</li>
  <li>A lab must work without the orchestrator.</li>
  <li>The future <code class="language-plaintext highlighter-rouge">netlab-qa</code> consumes contracts; it does not become a dependency of the labs.</li>
</ul>

<p>This direction makes it possible to learn from a real implementation before designing a
generic platform that might not match actual needs.</p>

<h2 id="an-installable-and-verifiable-foundation">An installable and verifiable foundation</h2>

<p>The first phase focuses on the foundation:</p>

<ul>
  <li>Python 3.12 and a <code class="language-plaintext highlighter-rouge">src</code> layout.</li>
  <li>An installable package and console entry point.</li>
  <li>A CLI with help, version, and defined exit codes.</li>
  <li>Unit and integration tests.</li>
  <li>Ruff and validation of the generated wheel.</li>
  <li>Documented requirements, architecture, and decisions.</li>
</ul>

<p>This foundation does not yet run the complete cycle. Publishing that limitation avoids
confusing a sound project structure with functionality that does not yet exist.</p>

<h2 id="next-milestone">Next milestone</h2>

<p>The next useful result will be controlling a real IRC service from start to finish: starting
it, detecting readiness, stopping it, and proving that no orphaned resources remain. From
there, each additional capability can grow from real evidence.</p>]]></content><author><name>Roxana Stancu</name></author><summary type="html"><![CDATA[Architecture principles and the initial scope of irc-netlab.]]></summary></entry></feed>