Lynn_tcp
is a lightweight TCP server framework
-
Lightweight: concise code that is easier to learn and use
-
Concurrent and Performance: Based on Tokio's excellent asynchronous performance, it is easy to achieve concurrent processing capabilities for multi-user links
-
Security: Code written with strong typing and memory safety in Rust
tips: Lynn_tcp is mainly used for message forwarding and long link TCP game servers
Quickly develop suitable business scenarios based on frameworks
Different message parsing, communication data encryption, and other operations can be achieved through custom settings
Make sure you activated the features which you need of the lynn_tcp on Cargo.toml:
full features
[dependencies]
lynn_tcp = { git = "https://github.com/cherish-ltt/lynn_tcp.git", branch = "main" }
server feature
[dependencies]
lynn_tcp = { git = "https://github.com/cherish-ltt/lynn_tcp.git", branch = "main", features = "server" }
client feature
[dependencies]
lynn_tcp = { git = "https://github.com/cherish-ltt/lynn_tcp.git", branch = "main", features = "client" }
use lynn_tcp::server::{HandlerResult, InputBufVO, LynnServerConfigBuilder, LynnServer};
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
let _ = LynnServer::new().await.add_router(1, my_service).start().await;
Ok(())
}
pub fn my_service(input_buf_vo: &mut InputBufVO) -> HandlerResult {
println!("service read from :{}", input_buf_vo.get_input_addr());
HandlerResult::new_without_send()
}
use lynn_tcp::server::{HandlerResult, InputBufVO, LynnServerConfigBuilder, LynnServer};
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
let _ = LynnServer::new_with_config(
LynnServerConfigBuilder::new()
.with_server_ipv4("0.0.0.0:9177")
.with_server_max_connections(Some(&200))
.with_server_max_threadpool_size(&10)
// ...more
.build(),
)
.await
.add_router(1, my_service)
.start()
.await;
Ok(())
}
pub fn my_service(input_buf_vo: &mut InputBufVO) -> HandlerResult {
println!("service read from :{}", input_buf_vo.get_input_addr());
HandlerResult::new_without_send()
}
server
: Provide customizable TCP services that can easily achieve multi-user long connections and concurrent processing capabilities, with services for different routesclient
: Provide custom TCP clients that can send messages to TCP servers and receive messages from servers, with different routing services
-
Tcp server
-
Tcp client
-
Custom message parsing
-
Automatically clean sockets
-
Routing service for synchronous tasks
Note:
All Basic functions support on v1.0.0 and above
- Scheduled tasks
- Middleware
- Global database handle
- Communication data encryption
- Routing service for asynchronous tasks
- Disconnecting reconnection mechanism
This project is licensed under the MIT license.
Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in Tokio by you, shall be licensed as MIT, without any additional terms or conditions.