udp
作者:
招风小妖怪 | 来源:发表于
2020-07-16 19:15 被阅读0次
const dgram = require('dgram');
const server = dgram.createSocket('udp4');
server.on('close',()=>{
console.log('socket已关闭');
});
server.on('error',(err)=>{
console.log(err);
});
server.on('listening',()=>{
console.log('socket正在监听中...');
});
server.on('message',(msg,rinfo)=>{
console.log(`receive message from ${rinfo.address}:${rinfo.port}`);
server.send('exit',rinfo.port,rinfo.address)
});
server.bind('1314');
本文标题:udp
本文链接:https://www.haomeiwen.com/subject/dirlbctx.html
网友评论