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.
- ⚡ 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
Application / Demo
│
▼
NetX (Bootstrap)
│
▼
TcpServer / TcpClient
│
▼
EventLoop (Reactor)
│
▼
Java NIO Selector
│
▼
SocketChannel (OS)
- One EventLoop owns one Selector
- All selector mutations happen on the owning thread
- Accept (Boss) thread never performs IO
- Transport layer is protocol-agnostic
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
- Java 17+
- Maven 3.8+
mvn clean compilejava -cp target/classes com.netx.demo.NetXMaintelnet localhost 8080Most 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
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.
- HTTP request/response server
- Write-queue & backpressure
- Buffer pooling
- HTTP/2 multiplexing
- Benchmarking vs Netty
- Publish to Maven Central
MIT License — free to use, modify, and learn from.