Crates.io | knetrs |
lib.rs | knetrs |
version | 0.1.1 |
source | src |
created_at | 2023-06-13 05:19:48.400996 |
updated_at | 2023-06-13 05:19:48.400996 |
description | A TCP library |
homepage | https://gitee.com/dennis-kk/knet |
repository | |
max_upload_size | |
id | 888703 |
size | 858,281 |
A TCP multi-threaded library.
let net = knet::KnetNetwork::new();
net.lock().unwrap().start();
net.lock().unwrap().on_accept(
|_network: &knet::KnetNetwork, _ip: &str, _port: i32, _success: bool| {
// Listen failed or successfully
},
);
net.lock().unwrap().on_connect(
|_network: &knet::KnetNetwork, _chan_id: u64, _ip: &str, _port: i32, _success: bool| {
// Connect failed or successfully
},
);
net.lock().unwrap().listen(String::from("127.0.0.1"), 12345);
net.lock().unwrap().connect(String::from("127.0.0.1"), 12345);
//
// Run tick in main loop every frame
//
net.lock().unwrap().tick();