const dgram = require('dgram'); const multicastAddr = '224.1.1.1'; let client = dgram.createSocket('udp4'); client.bind(6666, '0.0.0.0', function() { //将socket加入组播组中 client.addMembership(multicastAddr); }); client.on('message', function (msg, rinfo) { console.log(msg.toString()); });
node.js基于dgram数据报模块创建UDP服务器和客户端(2)
内容版权声明:除非注明,否则皆为本站原创文章。
转载注明出处:http://www.heiqu.com/8066cd554b0ca1d4397a1048dd0f91b7.html