Guest User

Untitled

a guest
Jul 31st, 2016
143
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. const dgram = require('dgram');
  2. const broadcastServer = dgram.createSocket('udp4');
  3.  
  4. broadcastServer.on('message', (msg, rinfo) => {
  5.   console.log(`server got: ${msg} from ${rinfo.address}:${rinfo.port}`);
  6.   broadcastServer.send(hostAddr, 0 , hostAddr.length, 35124, rinfo.address);
  7.   console.log(`server broadcast ${hostAddr} to ${rinfo.address}`);
  8. });
  9.  
  10. broadcastServer.bind(broadcastPort, function(){
  11.   broadcastServer.setBroadcast(true);
  12. });
Advertisement
Add Comment
Please, Sign In to add comment