Skip to content

feat: Upgrades networking to use io_uring.#2315

Merged
kamronbatman merged 2 commits intomainfrom
kbatman/io_ring
Feb 2, 2026
Merged

feat: Upgrades networking to use io_uring.#2315
kamronbatman merged 2 commits intomainfrom
kbatman/io_ring

Conversation

@kamronbatman
Copy link
Contributor

@kamronbatman kamronbatman commented Jan 18, 2026

Important

Breaking Changes

  • DecodePacket and EncodePacket delegates replaced with IClientEncryption interface
  • NetState.Connection (Socket) replaced with internal RingSocket management
  • NetState.RecvPipe and NetState.SendPipe removed (buffers managed internally)

Summary

Upgrades the networking stack from PollGroup-based I/O to io_uring, significantly improving I/O performance on Linux.
This also adds native client encryption support for encrypted UO clients.

Major Changes

io_uring Networking Architecture

  • Replaced PollGroup with IORingGroup for async socket I/O operations
  • Removed Pipe.cs (mirrored ring buffer) and TcpServer.cs in favor of RingSocketManager
  • Added NetState.Network.cs - centralized network infrastructure handling accept, recv, send, and disconnect
    completions
  • Added SocketHelper.cs - platform-specific socket utilities for raw socket handle operations (getpeername,
    getsockname)
  • Buffer management now handled by RingSocketManager with configurable slab allocation

Client Encryption Support

  • Added full encryption stack in Network/Encryption/:
    • EncryptionConfig.cs - configurable encryption modes (None, Unencrypted, Encrypted, Both)
    • EncryptionManager.cs - encryption detection and initialization for login/game packets
    • LoginEncryption.cs - handles login packet encryption with version-derived keys
    • GameEncryption.cs - handles game server encryption using Twofish
    • TwofishEngine.cs - optimized Twofish block cipher implementation
    • LoginKeys.cs - encryption key table for client versions
    • IClientEncryption.cs - interface for client encryption implementations

NetState Improvements

  • Replaced Socket Connection with RingSocket _socket for managed socket lifecycle
  • Changed from GCHandle polling to event-based completion processing
  • Disconnect handling now properly waits for pending sends to flush
  • Simplified connecting socket management using lazy queue removal

Configuration

  • New settings: network.encryptionMode and network.encryptionDebug
  • Encryption mode flags: Unencrypted, Encrypted, or Both

Dependencies

  • Replaced PollGroup NuGet package with IORingGroup
  • Linux requires liburing-dev / liburing-devel package

Test plan

  • Verify server starts and accepts connections on Linux with io_uring
  • Verify server starts and accepts connections on Windows (fallback to IOCP)
  • Test unencrypted client connections (ClassicUO with encryption disabled)
  • Test encrypted client connections if available
  • Verify graceful disconnect flushes pending data
  • Confirm CI builds pass on all target platforms

@kamronbatman kamronbatman force-pushed the kbatman/io_ring branch 3 times, most recently from daaf261 to 0c412ec Compare January 20, 2026 21:17
@kamronbatman kamronbatman changed the title [WIP] feat: Upgrades networking to use io_uring. feat: Upgrades networking to use io_uring. Jan 21, 2026
@kamronbatman kamronbatman marked this pull request as ready for review January 21, 2026 03:42
Copilot AI review requested due to automatic review settings January 21, 2026 03:42
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This pull request upgrades the networking infrastructure from a traditional socket polling approach to io_uring-based I/O on Linux and Windows RIO (Registered I/O). The changes introduce a new C native library for Windows RIO support, replace the core networking components (TcpServer, Pipe), and refactor NetState to use the new IORingGroup package.

Changes:

  • Adds new C native library (ioring.c/h) implementing Windows RIO with io_uring-compatible API
  • Replaces TcpServer and Pipe classes with new IORingGroup-based socket manager
  • Refactors NetState to use RingSocket/RingSocketManager instead of raw Socket/Pipe
  • Updates all test infrastructure to work with new networking model

Reviewed changes

Copilot reviewed 59 out of 59 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
Projects/ioring/ioring.vcxproj Visual Studio project for Windows RIO native library
Projects/ioring/ioring.h Header defining io_uring-compatible API for Windows RIO
Projects/ioring/ioring.c C implementation of Windows RIO with AcceptEx support
Projects/Server/Network/SocketHelper.cs Platform-specific utilities for socket handle introspection
Projects/Server/Network/NetState/NetState.cs Core NetState refactoring for new networking model
Projects/Server/Network/NetState/NetState.Network.cs New networking layer with RingSocketManager
Projects/Server/Server.csproj Package reference update from PollGroup to IORingGroup
Projects/UOContent/Misc/ServerList.cs Updated to use new LocalEndPoint property
Projects/Server.Tests/Helpers/PacketTestUtilities.cs Test helper updates for new socket creation
Various test files Updated SendPipe.Reader calls to SendBuffer.GetReadSpan

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@kamronbatman kamronbatman force-pushed the kbatman/io_ring branch 2 times, most recently from 8350e83 to 40452c0 Compare January 23, 2026 00:36
@kamronbatman kamronbatman merged commit 3c0d6cb into main Feb 2, 2026
8 of 9 checks passed
@kamronbatman kamronbatman deleted the kbatman/io_ring branch February 2, 2026 00:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant