<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:content="http://purl.org/rss/1.0/modules/content/">
  <channel>
    <title>MINA on Timmoc 的技术小屋</title>
    <link>https://t1mmoc.github.io/tags/mina/</link>
    <description>Recent content in MINA on Timmoc 的技术小屋</description>
    <generator>Hugo</generator>
    <language>zh-cn</language>
    <lastBuildDate>Sat, 17 Oct 2026 17:12:00 +0800</lastBuildDate>
    <atom:link href="https://t1mmoc.github.io/tags/mina/index.xml" rel="self" type="application/rss+xml" />
    <item>
      <title>【AIGC】自己定一个 TCP 帧协议：魔数、长度前缀、粘包，和一个把我救回来的全局开关</title>
      <link>https://t1mmoc.github.io/posts/2026-10-17-tcp-frame-protocol/</link>
      <pubDate>Sat, 17 Oct 2026 17:12:00 +0800</pubDate>
      <guid>https://t1mmoc.github.io/posts/2026-10-17-tcp-frame-protocol/</guid>
      <description>2023 年写了个 C/S 的东西，服务端 Java &#43; Apache MINA，客户端 C&#43;&#43; DLL，嫌 HTTP 不合适就自己定了协议：4 字节魔数 &#43; 4 字节长度 &#43; JSON 正文。事后看协议部分才是真正学到东西的地方——TCP 是字节流不是消息流，所以解码器必须变成状态机；状态不能放字段（MINA 的 decoder 是单例），我用了静态 HashMap 代价是泄漏和并发；length 字段在编码侧是字节数、在对象构造里是字符数，ASCII 下看不出来、中文差三倍；还有一个为了让某个会话别卡住而加的 static 全局开关，它会误伤所有会话。</description>
    </item>
  </channel>
</rss>
