High-performance TCP networking library for .NET 8 with pipeline-based message handling
- 🔥 High-performance pipeline-based I/O using
System.IO.Pipelines - 📦 Length-prefixed messaging with automatic framing
- 🔄 Multi-client server with concurrent connection handling
- 🛡️ Memory-safe with proper resource disposal
- ⚡ Zero-copy operations where possible
- 🎯 Simple API - connect, send, receive
using var server = new NexusServer(9000);
server.OnClientConnected += (connection) =>
Console.WriteLine("Client connected!");
server.OnMessageReceived += (connection, message) => {
var text = Encoding.UTF8.GetString(message.ToArray());
Console.WriteLine($"Received: {text}");
};
await server.StartAsync();using var client = new NexusClient();
client.OnMessageReceived += (message) => {
var text = Encoding.UTF8.GetString(message.ToArray());
Console.WriteLine($"Server: {text}");
};
await client.ConnectAsync("127.0.0.1", 9000);
await client.SendMessageAsync(Encoding.UTF8.GetBytes("Hello!"));# Terminal 1 - Start Server
cd Nexus.Server && dotnet run
# Terminal 2 - Start Client
cd Nexus.Client && dotnet run┌─────────────────┐ ┌─────────────────┐
│ NexusClient │ │ NexusServer │
├─────────────────┤ ├─────────────────┤
│ • Connect() │ │ • StartAsync() │
│ • Send() │ │ • Multi-client │
│ • Events │ │ • Events │
└─────────┬───────┘ └─────────┬───────┘
│ │
└──────┬─────────────┬──┘
│ │
┌────────▼─────────────▼────────┐
│ NexusConnection │
├──────────────────────────────┤
│ • Pipeline I/O │
│ • Message framing │
│ • Length prefixes (4 bytes) │
│ • Automatic buffering │
└──────────────────────────────┘
| Project | Description |
|---|---|
| Nexus.Core | Core networking library |
| Nexus.Server | Example TCP server |
| Nexus.Client | Example TCP client |
| Nexus.Benchmarks | Performance benchmarks with BenchmarkDotNet |
┌──────────────┬────────────────────┐
│ 4 bytes │ N bytes │
│ Length │ Payload │
│ (Little End) │ │
└──────────────┴────────────────────┘
All messages are automatically framed with a 4-byte little-endian length prefix.
dotnet build
dotnet test # (when tests are added)# Run all performance benchmarks
cd Nexus.Benchmarks && dotnet run -c Release
# Run specific benchmark categories
dotnet run -c Release -- --filter "*MessageThroughput*"
dotnet run -c Release -- --filter "*Connection*"See Nexus.Benchmarks for detailed performance analysis.
- Game servers - low-latency multiplayer communication
- Microservices - high-throughput service-to-service messaging
- IoT systems - efficient device communication
- Chat applications - real-time messaging
- File transfer - reliable bulk data transmission
- ✅ NexusServer: Thread-safe for multiple clients
- ✅ NexusClient: Thread-safe for concurrent operations
- ✅ NexusConnection: Internal synchronization handled
- Fork the repository
- Create a feature branch (
git checkout -b feature/amazing-feature) - Commit changes (
git commit -m 'Add amazing feature') - Push to branch (
git push origin feature/amazing-feature) - Open a Pull Request
MIT License - see LICENSE file for details.