1 unstable release

0.1.1 Jun 13, 2023

#27 in #multi-threaded

MIT license

345KB
8K SLoC

C 6.5K SLoC // 0.1% comments Rust 1.5K SLoC // 0.0% comments C++ 85 SLoC // 0.4% comments Shell 18 SLoC

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();

Dependencies

~0.6–0.9MB
~17K SLoC