https://github.com/mengps/qtkcp
🦊 基于 UDP 的 Qt Kcp 包装,使用方法与 QTcpServer / QTcpSocket 一致。
https://github.com/mengps/qtkcp
kcp qt udp
Last synced: 5 months ago
JSON representation
🦊 基于 UDP 的 Qt Kcp 包装,使用方法与 QTcpServer / QTcpSocket 一致。
- Host: GitHub
- URL: https://github.com/mengps/qtkcp
- Owner: mengps
- License: mit
- Created: 2023-02-10T04:35:46.000Z (over 2 years ago)
- Default Branch: master
- Last Pushed: 2024-10-23T16:57:39.000Z (12 months ago)
- Last Synced: 2025-05-05T22:13:11.892Z (5 months ago)
- Topics: kcp, qt, udp
- Language: C++
- Homepage:
- Size: 35.2 KB
- Stars: 7
- Watchers: 1
- Forks: 4
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
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