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