kcp-sys
Safe bindings to the kcp transport protocol library.
Also including a high level API for connection state management and data stream handling.
Usage
-
Create the endpoint and run it.
let mut endpoint = new; endpoint.run.await; -
forward the input and output to your transport layer, udp for example.
let = ; let udp_socket = new; udp_socket.connect.await.unwrap; let udp = udp_socket.clone; spawn; let udp = udp_socket.clone; spawn; -
Create a connection and send / recv data.
let conn_id = endpoint .connect .await .unwrap; let mut kcp_stream = new.unwrap; kcp_stream.write_all.await.unwrap; let mut buf = vec!; let size = kcp_stream.read.await.unwrap; println!;
Tune the kcp parameters
You can tune the kcp parameters by set a config factory to the endpoint.
let mut endpoint = new;
endpoint.set_kcp_config_factory;