knetrs

Crates.ioknetrs
lib.rsknetrs
version0.1.1
sourcesrc
created_at2023-06-13 05:19:48.400996
updated_at2023-06-13 05:19:48.400996
descriptionA TCP library
homepagehttps://gitee.com/dennis-kk/knet
repository
max_upload_size
id888703
size858,281
王宽宽 (dennis-kk)

documentation

README

knet

A TCP multi-threaded library.

sample

Listen and connect

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();
Commit count: 0

cargo fmt