跳到主要内容

KCP

基于 UDP 的可靠传输,弱网场景更稳。TLS 配置见 TLS

示例

服务端:

# orbien-server.toml
bindAddr = "0.0.0.0"
bindPort = 9527
kcpBindPort = 9529

[transport]
tcpMux = true

客户端:

# orbien.toml
serverAddr = "YOUR_SERVER_IP"
serverPort = 9529

[transport]
protocol = "kcp"
tcpMux = true
heartbeatInterval = -1

serverPort 需指向服务端 kcpBindPort,且不可与 quicBindPort 相同。

客户端参数

参数必填默认值说明
transport.protocoltcp固定为 kcp
serverPort填服务端 kcpBindPort
transport.tcpMuxtrueTCP 多路复用;需与服务端一致
transport.heartbeatInterval-1应用心跳间隔(秒);-1 关闭。关闭 tcpMux 时自动变为 30

服务端参数

参数必填默认值说明
kcpBindPort0KCP 监听端口(UDP);0 表示关闭;不可与 quicBindPort 相同
transport.tcpMuxtrueTCP 多路复用;需与客户端一致