# QtKcp **Repository Path**: stoneold/QtKcp ## Basic Information - **Project Name**: QtKcp - **Description**: https://github.com/mengps/QtKcp QtKcp 是基于 Qt 的 Kcp 包装库,底层使用 UDP 传输。 它简化了 Kcp 的使用。 - **Primary Language**: C++ - **License**: MIT - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 0 - **Created**: 2024-11-10 - **Last Updated**: 2024-12-15 ## Categories & Tags **Categories**: Uncategorized **Tags**: Qt ## README # QtKcp `QtKcp` 是基于 Qt 的 Kcp 包装库,底层使用 UDP 传输。 它简化了 Kcp 的使用。 `Kcp` 地址:https://github.com/skywind3000/kcp ---- ### 如何构建 克隆仓库 ```bash git clone https://github.com/mengps/QtKcp && cd QtKcp git submodule update --init ``` `cmake` 构建: ```cmake mkdir build && cd build cmake .. cmake --build . cmake --install ``` `qmake` 构建: 使用 `QtKcp.pro` --- ### 如何使用 Server 端: ```c++ QKcpServer server; server.listen(QHostAddress::Any, 12345); ``` Client 端: ```c++ QKcpSocket client; client->connectToHost(QHostAddress("127.0.0.1"), 12345); ``` 其行为和接口基本与 QTcpServer / QTcpSocket 一致。 当然还远不够完善,将会根据需要添加。 ---- ### 注意 为了完成 UDP -> 类 TCP 的转变,实现会稍微有点奇怪:连接的端口会在连接成功时改变。 这是因为主机 (Server) 只负责监听连接,真正的连接将使用新的端口进行。 --- ### 许可证 使用 `MIT LICENSE` --- ### 开发环境 Windows 11,Qt 5.15.2 / Qt 6.7.3