Skip to content

NetX is a high-performance Java networking framework built from scratch using Java NIO and the Reactor Pattern. It provides a low-level yet extensible transport layer for building scalable TCP/HTTP systems, featuring non-blocking I/O, custom protocol support, connection management, and production-grade architecture inspired by Netty-style internals

License

Notifications You must be signed in to change notification settings

mukeshlilawat1/NetX-High-Performance-Java-Networking-Framework

Repository files navigation

🚀 NetX — High-Performance Java Networking Framework

NetX is a library-level, high-performance networking framework built from scratch using Core Java (Java NIO) and the Reactor Pattern.
It is designed to provide a deep, practical understanding of how modern networking frameworks (like Netty) work internally — without hiding complexity behind abstractions.

⚠️ NetX is not an application.
✅ It is a reusable networking engine intended to be embedded into other systems.


✨ Key Features

  • Non-blocking I/O using Java NIO (Selector, SocketChannel)
  • 🔁 Reactor Pattern with selector-owning event loops
  • 🧵 Boss–Worker architecture
  • 🔒 Thread-safe selector registration via task queue
  • 🔌 TCP Server & Client transport
  • 🧩 Clean Channel abstraction
  • 🧠 Defensive handling of CancelledKeyException
  • ♻️ Idempotent channel lifecycle management
  • 🧪 Runnable demo for validation
  • ❌ No Spring, No Netty — pure systems-level Java

🏗️ Architecture Overview

Application / Demo
        │
        ▼
     NetX (Bootstrap)
        │
        ▼
   TcpServer / TcpClient
        │
        ▼
     EventLoop (Reactor)
        │
        ▼
   Java NIO Selector
        │
        ▼
   SocketChannel (OS)

Core Principles

  • One EventLoop owns one Selector
  • All selector mutations happen on the owning thread
  • Accept (Boss) thread never performs IO
  • Transport layer is protocol-agnostic

📁 Project Structure

netx/
├── pom.xml
├── README.md
└── src/main/java/com/netx
    ├── NetX.java
    │
    ├── demo/
    │   └── NetXMain.java
    │
    ├── core/
    │   ├── Reactor.java
    │   ├── EventLoop.java
    │   └── SelectorManager.java
    │
    ├── transport/
    │   ├── Channel.java
    │   ├── TcpChannel.java
    │   ├── TcpServer.java
    │   └── TcpClient.java
    │
    ├── protocol/
    │   ├── Protocol.java
    │   ├── HttpProtocol.java
    │   └── BinaryProtocol.java
    │
    ├── http/
    │   ├── HttpRequest.java
    │   ├── HttpResponse.java
    │   ├── HttpParser.java
    │   └── HttpEncoder.java
    │
    ├── concurrency/
    │   ├── WorkerPool.java
    │   └── NetxThreadFactory.java
    │
    ├── pipeline/
    │   ├── Filter.java
    │   ├── FilterChain.java
    │   ├── LoggingFilter.java
    │   └── AuthFilter.java
    │
    ├── resilience/
    │   ├── RetryPolicy.java
    │   └── CircuitBreaker.java
    │
    ├── metrics/
    │   ├── LatencyTracker.java
    │   └── ThroughputMeter.java
    │
    └── ssl/
        └── SslContextFactory.java

▶️ Running the Demo

Prerequisites

  • Java 17+
  • Maven 3.8+

Compile

mvn clean compile

Run

java -cp target/classes com.netx.demo.NetXMain

Test

telnet localhost 8080

🧠 Why NetX Exists

Most developers use networking frameworks.
Very few understand how they work internally.

NetX was built to:

  • Learn Java NIO deeply
  • Understand Reactor Pattern in practice
  • Design production-grade event loops
  • Handle real-world race conditions
  • Write framework-level (not app-level) code

📌 Resume-Ready Description

Designed and implemented NetX, a high-performance Java networking framework using Java NIO and the Reactor Pattern, featuring selector-based event loops, thread-safe channel registration, and a boss–worker TCP transport architecture.


🛣️ Roadmap

  • HTTP request/response server
  • Write-queue & backpressure
  • Buffer pooling
  • HTTP/2 multiplexing
  • Benchmarking vs Netty
  • Publish to Maven Central

📜 License

MIT License — free to use, modify, and learn from.

About

NetX is a high-performance Java networking framework built from scratch using Java NIO and the Reactor Pattern. It provides a low-level yet extensible transport layer for building scalable TCP/HTTP systems, featuring non-blocking I/O, custom protocol support, connection management, and production-grade architecture inspired by Netty-style internals

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages