{"id":24791469,"url":"https://github.com/easytier/kcp-sys","last_synced_at":"2025-07-27T14:33:59.140Z","repository":{"id":272048185,"uuid":"914900324","full_name":"EasyTier/kcp-sys","owner":"EasyTier","description":"Safe bindings for KCP transport protocol.","archived":false,"fork":false,"pushed_at":"2025-02-08T15:32:16.000Z","size":44,"stargazers_count":5,"open_issues_count":0,"forks_count":3,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-07-15T14:51:52.953Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Rust","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/EasyTier.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2025-01-10T14:41:00.000Z","updated_at":"2025-06-02T17:16:15.000Z","dependencies_parsed_at":"2025-01-11T18:30:41.085Z","dependency_job_id":"6c984f72-c610-4216-9fab-58bcc7358a89","html_url":"https://github.com/EasyTier/kcp-sys","commit_stats":null,"previous_names":["easytier/kcp-sys"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/EasyTier/kcp-sys","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/EasyTier%2Fkcp-sys","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/EasyTier%2Fkcp-sys/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/EasyTier%2Fkcp-sys/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/EasyTier%2Fkcp-sys/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/EasyTier","download_url":"https://codeload.github.com/EasyTier/kcp-sys/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/EasyTier%2Fkcp-sys/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":267370646,"owners_count":24076462,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-07-27T02:00:11.917Z","response_time":82,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2025-01-29T19:17:05.628Z","updated_at":"2025-07-27T14:33:59.065Z","avatar_url":"https://github.com/EasyTier.png","language":"Rust","funding_links":[],"categories":[],"sub_categories":[],"readme":"# kcp-sys\n\nSafe bindings to the [kcp](https://github.com/skywind3000/kcp) transport protocol library.\n\nAlso including a high level API for connection state management and data stream handling.\n\n## Usage\n\n1. Create the endpoint and run it.\n\n    ```rust\n    let mut endpoint = KcpEndpoint::new();\n    endpoint.run().await;\n    ```\n\n2. forward the input and output to your transport layer, udp for example.\n\n    ```rust\n    let (input, mut output) = (endpoint.input_sender(), endpoint.output_receiver().unwrap());\n\n    let udp_socket = Arc::new(UdpSocket::bind(\"0.0.0.0:54320\").await.unwrap());\n    udp_socket.connect(\"127.0.0.1:54321\").await.unwrap();\n\n    let udp = udp_socket.clone();\n    tokio::spawn(async move {\n        while let Some(data) = output.recv().await {\n            udp.send(\u0026data.inner()).await.unwrap();\n        }\n    });\n\n    let udp = udp_socket.clone();\n    tokio::spawn(async move {\n        loop {\n            let mut buf = vec![0; 1024];\n            let (size, _) = udp.recv_from(\u0026mut buf).await.unwrap();\n            input\n                .send(BytesMut::from(\u0026buf[..size]).into())\n                .await\n                .unwrap();\n        }\n    });\n    ```\n4. Create a connection and send / recv data.\n\n    ```rust\n    let conn_id = endpoint\n        .connect(Duration::from_secs(1), 0, 0, Bytes::new())\n        .await\n        .unwrap();\n\n    let mut kcp_stream = KcpStream::new(\u0026endpoint, conn_id).unwrap();\n    kcp_stream.write_all(b\"hello world\").await.unwrap();\n\n    let mut buf = vec![0; 64 * 1024];\n    let size = kcp_stream.read(\u0026mut buf).await.unwrap();\n\n    println!(\"{}\", String::from_utf8_lossy(\u0026buf[..size]));\n    ```\n\n## Tune the kcp parameters\n\nYou can tune the kcp parameters by set a config factory to the endpoint.\n\n```rust\nlet mut endpoint = KcpEndpoint::new();\nendpoint.set_kcp_config_factory(|conv| {\n    KcpConfig::new_turbo(conv)\n});\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Feasytier%2Fkcp-sys","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Feasytier%2Fkcp-sys","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Feasytier%2Fkcp-sys/lists"}