mill-net
High-level networking components library built on top of mill-io, providing connection management and a simple handler-based API.
Features
- Connection management: Automatic handling of accept, read, write, and close
- Handler-based API: Implement simple traits to handle network events
- Configurable: Buffer sizes, connection limits, TCP options
- Thread-safe: Safe to use across multiple threads
Installation
[]
= "2.0.1"
Quick Start
TCP Server
use ;
use ;
use Arc;
;
Server Context Operations
The ServerContext provides methods for interacting with connections:
// Send data to a specific connection
ctx.send_to?;
// Broadcast to all connections
ctx.broadcast?;
// Close a connection
ctx.close_connection?;
Configuration
use TcpServerConfig;
use Duration;
let config = builder
.address
.buffer_size // Read buffer size
.max_connections // Connection limit
.no_delay // Disable Nagle's algorithm
.keep_alive
.build;
Configuration Options
| Option | Default | Description |
|---|---|---|
address |
Required | Socket address to bind |
buffer_size |
8192 | Read buffer size per connection |
max_connections |
1024 | Maximum concurrent connections |
no_delay |
false | Disable Nagle's algorithm (TCP_NODELAY) |
keep_alive |
None | TCP keep-alive interval |
License
Licensed under the Apache License, Version 2.0. See LICENSE for details.