⚡ Ultra-fast asynchronous networking for the FastJava ecosystem.
FastNet is a low-latency transport engine for telemetry, game servers, crawlers and real-time services. It exposes a compact asynchronous API today and provides a clear native boundary for WinSock2, IOCP and direct-memory ring buffers on Windows.
Run the TCP Loopback Demo | Run the UDP Benchmark
import fastnet.FastNet;
import java.nio.ByteBuffer;
import java.nio.charset.StandardCharsets;
public class Example {
public static void main(String[] args) {
FastNet.sendUdp("127.0.0.1", 9999,
ByteBuffer.wrap("telemetry".getBytes(StandardCharsets.UTF_8)))
.thenAccept(bytes -> System.out.println("Sent bytes: " + bytes));
}
}- Why FastNet?
- Quick Start
- Features
- Real-World Scenarios
- Performance Benchmarks
- API Quick Reference
- Technical Examples & Hero Demos
- Installation
- Documentation
- Platform Support
- License
- Related Projects
Standard blocking networking creates thread pressure and makes high-frequency services pay for unnecessary copies and polling:
- Thread exhaustion: One blocking connection per worker does not scale cleanly for burst traffic.
- Buffer copies: Heap-to-native transitions add latency to telemetry and packet pipelines.
- Polling overhead: Application loops waste CPU while waiting for kernel I/O completion.
FastNet addresses this with a transport-first design:
- Asynchronous completion: TCP and UDP operations return futures instead of blocking application threads.
- Direct-buffer boundary: Payloads can be supplied as
ByteBuffervalues without changing caller state. - Native-ready transport: WinSock2 and IOCP can replace the portable fallback behind the same API.
- ⚡ Asynchronous TCP and UDP: Connect and send without a polling loop in application code.
- 📦 Direct buffer support: Submit heap or direct
ByteBufferpayloads without mutating them. - 🪟 Windows native path: Designed for WinSock2, IOCP and kernel completion events.
- 🔗 Ecosystem ready: Integrates naturally with FastDNS resolution and FastTLS security.
- Live telemetry: Send compact UDP metrics from a sensor or game loop.
- Game servers: Establish low-latency TCP control channels and UDP state updates.
- Web crawling: Resolve endpoints with FastDNS and submit concurrent HTTP work.
- Secure services: Place FastTLS directly above the transport boundary.
FastNet includes a local UDP benchmark to expose transport overhead before the native IOCP backend is enabled.
| Metric / Transport Type | Current Java Fallback | Native Target |
|---|---|---|
| UDP submission | Measured by benchmark | IOCP / zero-copy |
| TCP connection | Asynchronous NIO | Native WinSock2 |
| Telemetry payload | Direct-buffer ready | Ring-buffer DMA |
The benchmark measures the portable Java path on the local machine. Native latency figures are reported only after IOCP integration.
The optimized local telemetry benchmark completed 100 UDP packets in 28,968 ms on this Windows workstation; the previous per-call channel setup measured 77,006 ms, so channel reuse reduced this run by about 62%.
run-benchmark.bat -> fastnet.UdpThroughputBenchmark
Native IOCP and zero-copy measurements must be collected separately after the Windows backend is enabled.
| Method | Description |
|---|---|
| Method | Description |
| -------- | ------------- |
connect(host, port) |
Opens an asynchronous TCP connection. |
sendUdp(host, port, payload) |
Sends a direct or heap ByteBuffer asynchronously. |
| Case | Java Example | Launcher | Description |
|---|---|---|---|
| TCP Telemetry Channel | TcpLoopbackDemo.java | run-demo.bat |
Establishes a local control channel and receives a telemetry response. |
| UDP Throughput | UdpThroughputBenchmark.java | run-benchmark.bat |
Measures repeated UDP submissions for a packet pipeline. |
<repositories>
<repository>
<id>jitpack.io</id>
<url>https://jitpack.io</url>
</repository>
</repositories>
<dependencies>
<dependency>
<groupId>com.github.andrestubbe</groupId>
<artifactId>FastNet</artifactId>
<version>0.1.0</version>
</dependency>
</dependencies>repositories {
maven { url 'https://jitpack.io' }
}
dependencies {
implementation 'com.github.andrestubbe:FastNet:0.1.0'
}Download the latest FastNet JAR from the GitHub releases page.
- COMPILE.md: Full compilation guide and launcher instructions.
- REFERENCE.md: Transport API and buffer contract.
- PHILOSOPHY.md: Native-first networking principles.
- ROADMAP.md: Planned IOCP and zero-copy milestones.
- CHANGELOG.md: Version history.
| Platform | Status |
|---|---|
| Windows 10/11 x64 | Native backend planned |
| Linux | Java fallback |
| macOS | Java fallback |
MIT License — See LICENSE for details.
- FastTLS — TLS transport security
- FastDNS — Asynchronous hostname resolution
- FastSharedMemory — Off-heap data exchange
Part of the FastJava Ecosystem — Making the JVM faster. Small package. Maximum speed. Zero bloat. 🚀📋