kcp-transceiver
v0.1.0
Published
基于KCP的UDP收发器,可以很方便在多台主机之间进行双向收发通信
Downloads
5
Readme
Host-1
const kcpTransceiver = require('kcp-transceiver');
const kcpTran = new kcpTransceiver({
listenPort: 5080,
listenCallback: (buf, address, port) => {
console.log(buf, `${address}:${port}`);
}
})
kcpTran.send({
buf: payload,
address: host_2_address,
port: 5081
})
Host-2
const kcpTransceiver = require('kcp-transceiver');
const kcpTran = new kcpTransceiver({
listenPort: 5081,
listenCallback: (buf, address, port) => {
console.log(buf, `${address}:${port}`);
}
})
kcpTran.send({
buf: payload,
address: host_1_address,
port: 5080
})