使用nodejs发送和接受tcp请求 // 使用 promise-socket 同步执行 const {PromiseSocket} = require("promise-socket") const client = async (path, fileName) => { const socket = new PromiseSocket(); socket.setTimeout(1000) await socket.connect({host:ip, port:port}); let response = await socket.read(1) await socket.write(Buffer.from([IP.length%16, IP.length/16])); await socket.end(); return true; } tcp 是以字节流来发送和接受数据,通过wireshark可以看到 00 50 56 99 e8 00 3c fd fe 7c 78 01 08 00 45 00 00 3
使用nodejs发送和接受tcp请求
最新推荐文章于 2023-03-02 17:25:21 发布
![](https://img-home.csdnimg.cn/images/20240711042549.png)